﻿using System;
using System.Collections.Generic;
using netDxf;
using netDxf.Entities;
using netDxf.Header;
using netDxf.Tables;

namespace TestDxfDocument
{
    class SolidMillingCuttersWithArborHole
    {
        public static void SolidPlainMillingCutter(Dictionary<string, Object> data)  //圆柱形铣刀
        {
            DxfDocument dxf = new DxfDocument();
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);
            //作图
            //参数
            double soal = Convert.ToDouble(data["oal"]);
            double sdc = Convert.ToDouble(data["dc"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0)
            {
                if (sdc < 39 && soal < 90)
                {
                    scale = 4.0;
                }
                else if (sdc < 52 && soal < 120)
                {
                    scale = 3.0;
                }
                else if (sdc < 78 && soal < 180)
                {
                    scale = 2.0;
                }
                else if (sdc < 104 && soal < 240)
                {
                    scale = 1.5;
                }
                else if (sdc < 156 && soal < 360)
                {
                    scale = 1.0;
                }
                else if (sdc < 208 && soal < 480)
                {
                    scale = 0.75;
                }
                else
                {
                    scale = 0.5;
                }
            }
            double dc = Convert.ToDouble(data["dc"]) * scale;
            double dcon = Convert.ToDouble(data["dcon"]) * scale;
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double dhub = Convert.ToDouble(data["dhub"]) * scale;
            double cw = Convert.ToDouble(data["cw"]) * scale;
            double hhub = (oal - cw) / 2;
            double bcd = Convert.ToDouble(data["bcd"]) * scale;
            if (bcd == 0)
            {
                bcd = dc - 4 * scale;
            }
            double bcdpax = Convert.ToDouble(data["bcdpax"]) * scale;
            double dccb = Convert.ToDouble(data["dccb"]) * scale;
            double lccb = Convert.ToDouble(data["lccb"]) * scale;
            double isframe = Convert.ToDouble(data["isframe"]);
            string path = Convert.ToString(data["path"]);
            //坐标
            //主视图
            if (dccb == 0)
            {
                Vector2 v1 = new Vector2(0, dhub / 2);
                Vector2 v2 = new Vector2(-hhub, v1.Y);
                Vector2 v3 = new Vector2(v2.X, dc / 2);
                Vector2 v4 = new Vector2(-oal + hhub, v3.Y);
                Vector2 v5 = new Vector2(v4.X, v2.Y);
                Vector2 v6 = new Vector2(-oal, v5.Y);
                Vector2 v7 = new Vector2(v6.X, -v6.Y);
                Vector2 v8 = new Vector2(v5.X, -v5.Y);
                Vector2 v9 = new Vector2(v4.X, -v4.Y);
                Vector2 v10 = new Vector2(v3.X, -v3.Y);
                Vector2 v11 = new Vector2(v2.X, -v2.Y);
                Vector2 v12 = new Vector2(v1.X, -v1.Y);
                Vector2 v13 = new Vector2(v2.X - bcdpax, v2.Y);
                Vector2 v14 = new Vector2(v13.X, bcd / 2);
                Vector2 v15 = new Vector2(v4.X + bcdpax, v14.Y);
                Vector2 v16 = new Vector2(v15.X, v13.Y);
                Vector2 v17 = new Vector2(v16.X, -v16.Y);
                Vector2 v18 = new Vector2(v15.X, -v15.Y);
                Vector2 v19 = new Vector2(v14.X, -v14.Y);
                Vector2 v20 = new Vector2(v13.X, -v13.Y);
                Vector2 v21 = new Vector2(v6.X, dcon / 2);
                Vector2 v22 = new Vector2(0, v21.Y);
                Vector2 v23 = new Vector2(v21.X, -v21.Y);
                Vector2 v24 = new Vector2(v22.X, -v22.Y);
                Vector2 v25 = new Vector2(-oal - 2, 0);
                Vector2 v26 = new Vector2(2, 0);
                //线段
                //主视图
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                Vector2[] Line3 = { v3, v4 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v4, v5 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v5, v6 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v6, v7 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                Vector2[] Line7 = { v7, v8 };
                fun.drawBLine(dxf, Line7, 0.3, contour);
                Vector2[] Line8 = { v8, v9 };
                fun.drawBLine(dxf, Line8, 0.3, contour);
                Vector2[] Line9 = { v9, v10 };
                fun.drawBLine(dxf, Line9, 0.3, contour);
                Vector2[] Line10 = { v10, v11 };
                fun.drawBLine(dxf, Line10, 0.3, contour);
                Vector2[] Line11 = { v11, v12 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                Vector2[] Line12 = { v12, v1 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line13 = { v13, v14 };
                fun.drawBLine(dxf, Line13, 0.3, contour);
                Vector2[] Line14 = { v14, v15 };
                fun.drawBLine(dxf, Line14, 0.3, contour);
                Vector2[] Line15 = { v15, v16 };
                fun.drawBLine(dxf, Line15, 0.3, contour);
                Vector2[] Line16 = { v13, v2 };
                fun.drawBLine(dxf, Line16, 0.3, contour);
                Vector2[] Line17 = { v16, v5 };
                fun.drawBLine(dxf, Line17, 0.3, contour);
                Vector2[] Line18 = { v18, v19 };
                fun.drawBLine(dxf, Line18, 0.3, contour);
                Vector2[] Line19 = { v19, v20 };
                fun.drawBLine(dxf, Line19, 0.3, contour);
                Vector2[] Line20 = { v20, v11 };
                fun.drawBLine(dxf, Line20, 0.3, contour);
                Vector2[] Line21 = { v8, v17 };
                fun.drawBLine(dxf, Line21, 0.3, contour);
                Vector2[] Line22 = { v21, v22 };
                fun.drawPlinetype(dxf, Line22, 0.15, refin, Linetype.Dashed);
                Vector2[] Line23 = { v23, v24 };
                fun.drawBLine(dxf, Line23, 0.3, contour);
                Vector2[] Line24 = { v25, v26 };
                fun.drawPlinetype(dxf, Line24, 0.15, center, Linetype.Center);
                Vector2[] Line25 = { v5, new Vector2(v5.X, 0) };
                fun.drawBLine(dxf, Line25, 0.3, contour);
                Vector2[] Line26 = { v2, new Vector2(v2.X, 0) };
                fun.drawBLine(dxf, Line26, 0.3, contour);
                Vector2[] Line27 = { v17, v18 };
                fun.drawBLine(dxf, Line27, 0.3, contour);
                //填充
                LwPolyline hatchpoly1 = new LwPolyline();
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v2));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v3));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v4));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v5));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v16));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v15));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v14));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v13));
                hatchpoly1.IsClosed = true;
                String[] htype1 = new String[100];
                Line[] hline1 = new Line[100];
                int hnumst1 = hatchpoly1.Explode().Count;  //记录爆炸后，线段有多少
                for (int i = 0; i < hnumst1; i++)
                {
                    htype1[i] = hatchpoly1.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                    if (htype1[i] == "Line")
                    {
                        hline1[i] = (Line)hatchpoly1.Explode()[i];
                    }
                }
                fun.hatchsuboflinew(dxf, htype1, hnumst1, 45, 0.5 * scale, hline1, contour, 0.5);
                LwPolyline hatchpoly2 = new LwPolyline();
                hatchpoly2.Vertexes.Add(new LwPolylineVertex(v8));
                hatchpoly2.Vertexes.Add(new LwPolylineVertex(v9));
                hatchpoly2.Vertexes.Add(new LwPolylineVertex(v10));
                hatchpoly2.Vertexes.Add(new LwPolylineVertex(v11));
                hatchpoly2.Vertexes.Add(new LwPolylineVertex(v20));
                hatchpoly2.Vertexes.Add(new LwPolylineVertex(v19));
                hatchpoly2.Vertexes.Add(new LwPolylineVertex(v18));
                hatchpoly2.Vertexes.Add(new LwPolylineVertex(v17));
                hatchpoly2.IsClosed = true;
                String[] htype2 = new String[100];
                Line[] hline2 = new Line[100];
                int hnumst2 = hatchpoly2.Explode().Count;  //记录爆炸后，线段有多少
                for (int i = 0; i < hnumst2; i++)
                {
                    htype2[i] = hatchpoly2.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                    if (htype2[i] == "Line")
                    {
                        hline2[i] = (Line)hatchpoly2.Explode()[i];
                    }
                }
                fun.hatchsuboflinew(dxf, htype2, hnumst2, 45, 0.5 * scale, hline2, contour, 0.5);
                LwPolyline hatchpoly3 = new LwPolyline();
                hatchpoly3.Vertexes.Add(new LwPolylineVertex(v23));
                hatchpoly3.Vertexes.Add(new LwPolylineVertex(v24));
                hatchpoly3.Vertexes.Add(new LwPolylineVertex(v12));
                hatchpoly3.Vertexes.Add(new LwPolylineVertex(v20));
                hatchpoly3.Vertexes.Add(new LwPolylineVertex(v19));
                hatchpoly3.Vertexes.Add(new LwPolylineVertex(v18));
                hatchpoly3.Vertexes.Add(new LwPolylineVertex(v17));
                hatchpoly3.Vertexes.Add(new LwPolylineVertex(v7));
                hatchpoly3.IsClosed = true;
                String[] htype3 = new String[100];
                Line[] hline3 = new Line[100];
                int hnumst3 = hatchpoly3.Explode().Count;  //记录爆炸后，线段有多少
                for (int i = 0; i < hnumst3; i++)
                {
                    htype3[i] = hatchpoly3.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                    if (htype3[i] == "Line")
                    {
                        hline3[i] = (Line)hatchpoly3.Explode()[i];
                    }
                }
                fun.hatchsubofline(dxf, htype3, hnumst3, 45, 5, hline3, hatching);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 1.0;
                double offset = 10;
                //线段尺寸标注
                //尺寸1
                LinearDimension dim1 = new LinearDimension(new Line(v10, v9), -offset, 0, dimensionStyle);
                dim1.UserText = "CW = " + Math.Round(cw / scale, 2);
                dxf.AddEntity(dim1);
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(v4, v9), -offset * 2 - hhub, 270, dimensionStyle);
                dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸3
                LinearDimension dim3 = new LinearDimension(new Line(v7, v9), -offset - (v12.Y - v10.Y) / 2, 0, dimensionStyle);
                dim3.UserText = "HHUB = " + Math.Round(hhub / scale, 2);
                dxf.AddEntity(dim3);
                //尺寸4
                if (bcdpax != 0)
                {
                    LinearDimension dim4 = new LinearDimension(new Line(v19, v10), -offset - (v19.Y - v10.Y) / 2, 0, dimensionStyle);
                    dim4.UserText = "BCDPAX = " + Math.Round(bcdpax / scale, 2);
                    dxf.AddEntity(dim4);
                }
                //尺寸5
                LinearDimension dim5 = new LinearDimension(new Line(v7, v12), -offset * 2 - v7.Y + v9.Y, 0, dimensionStyle);
                dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                dxf.AddEntity(dim5);
                //尺寸6
                LinearDimension dim6 = new LinearDimension(new Line(v22, v24), offset, 270, dimensionStyle);
                dim6.UserText = "DCON = " + Math.Round(dcon / scale, 2);
                dxf.AddEntity(dim6);
                //尺寸7
                LinearDimension dim7 = new LinearDimension(new Line(v7, v6), -offset, 270, dimensionStyle);
                dim7.UserText = "DHUB = " + Math.Round(dhub / scale, 2);
                dxf.AddEntity(dim7);
                //尺寸8
                LinearDimension dim8 = new LinearDimension(new Line(v14, v19), offset * 2 - v14.X, 270, dimensionStyle);
                dim8.UserText = "BCD = " + Math.Round(bcd / scale, 2);
                dxf.AddEntity(dim8);
            }
            if (dccb != 0)
            {
                Vector2 v1 = new Vector2(0, dhub / 2);
                Vector2 v2 = new Vector2(-hhub, v1.Y);
                Vector2 v3 = new Vector2(v2.X, dc / 2);
                Vector2 v4 = new Vector2(-oal, v3.Y);
                Vector2 v5 = new Vector2(v4.X, -v4.Y);
                Vector2 v6 = new Vector2(v3.X, -v3.Y);
                Vector2 v7 = new Vector2(v2.X, -v2.Y);
                Vector2 v8 = new Vector2(v1.X, -v1.Y);
                Vector2 v9 = new Vector2(v2.X - bcdpax, v2.Y);
                Vector2 v10 = new Vector2(v9.X, bcd / 2);
                Vector2 v11 = new Vector2(v4.X + bcdpax, v10.Y);
                Vector2 v12 = new Vector2(v11.X, dccb / 2);
                Vector2 v13 = new Vector2(v12.X, -v12.Y);
                Vector2 v14 = new Vector2(v11.X, -v11.Y);
                Vector2 v15 = new Vector2(v10.X, -v10.Y);
                Vector2 v16 = new Vector2(v9.X, -v9.Y);
                Vector2 v17 = new Vector2(v4.X, v12.Y);
                Vector2 v18 = new Vector2(-oal + lccb, v17.Y);
                Vector2 v19 = new Vector2(v18.X, dcon / 2);
                Vector2 v20 = new Vector2(v1.X, v19.Y);
                Vector2 v21 = new Vector2(v20.X, -v20.Y);
                Vector2 v22 = new Vector2(v19.X, -v19.Y);
                Vector2 v23 = new Vector2(v18.X, -v18.Y);
                Vector2 v24 = new Vector2(v17.X, -v17.Y);
                Vector2 v25 = new Vector2(-oal - 2, 0);
                Vector2 v26 = new Vector2(2, 0);
                //线段
                //主视图
                Vector2[] Line1 = { v1, v9 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                Vector2[] Line3 = { v3, v4 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v4, v5 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v5, v6 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v6, v7 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                Vector2[] Line7 = { v16, v8 };
                fun.drawBLine(dxf, Line7, 0.3, contour);
                Vector2[] Line8 = { v8, v1 };
                fun.drawBLine(dxf, Line8, 0.3, contour);
                Vector2[] Line9 = { v9, v10 };
                fun.drawBLine(dxf, Line9, 0.3, contour);
                Vector2[] Line10 = { v10, v11 };
                fun.drawBLine(dxf, Line10, 0.3, contour);
                Vector2[] Line11 = { v11, v12 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                Vector2[] Line12 = { v17, v18 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line13 = { v13, v14 };
                fun.drawBLine(dxf, Line13, 0.3, contour);
                Vector2[] Line14 = { v14, v15 };
                fun.drawBLine(dxf, Line14, 0.3, contour);
                Vector2[] Line15 = { v15, v16 };
                fun.drawBLine(dxf, Line15, 0.3, contour);
                Vector2[] Line16 = { v13, v24 };
                fun.drawBLine(dxf, Line16, 0.3, contour);
                Vector2[] Line17 = { v18, new Vector2(v18.X, 0) };
                fun.drawBLine(dxf, Line17, 0.3, contour);
                Vector2[] Line18 = { v19, v20 };
                fun.drawBLine(dxf, Line18, 0.3, contour);
                Vector2[] Line19 = { v7, new Vector2(v7.X, 0) };
                fun.drawBLine(dxf, Line19, 0.3, contour);
                Vector2[] Line20 = { v13, v23 };
                fun.drawPlinetype(dxf, Line20, 0.15, refin, Linetype.Dashed);
                Vector2[] Line21 = { v23, new Vector2(v23.X, 0) };
                fun.drawPlinetype(dxf, Line21, 0.15, refin, Linetype.Dashed);
                Vector2[] Line22 = { v21, v22 };
                fun.drawPlinetype(dxf, Line22, 0.15, refin, Linetype.Dashed);
                Vector2[] Line23 = { v25, v26 };
                fun.drawPlinetype(dxf, Line23, 0.15, center, Linetype.Center);
                //填充
                LwPolyline hatchpoly1 = new LwPolyline();
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v2));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v3));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v4));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v17));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v12));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v11));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v10));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v9));
                hatchpoly1.IsClosed = true;
                String[] htype1 = new String[100];
                Line[] hline1 = new Line[100];
                int hnumst1 = hatchpoly1.Explode().Count;  //记录爆炸后，线段有多少
                for (int i = 0; i < hnumst1; i++)
                {
                    htype1[i] = hatchpoly1.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                    if (htype1[i] == "Line")
                    {
                        hline1[i] = (Line)hatchpoly1.Explode()[i];
                    }
                }
                fun.hatchsuboflinew(dxf, htype1, hnumst1, 45, 0.5 * scale, hline1, contour, 0.5);
                LwPolyline hatchpoly2 = new LwPolyline();
                hatchpoly2.Vertexes.Add(new LwPolylineVertex(v24));
                hatchpoly2.Vertexes.Add(new LwPolylineVertex(v5));
                hatchpoly2.Vertexes.Add(new LwPolylineVertex(v6));
                hatchpoly2.Vertexes.Add(new LwPolylineVertex(v7));
                hatchpoly2.Vertexes.Add(new LwPolylineVertex(v16));
                hatchpoly2.Vertexes.Add(new LwPolylineVertex(v15));
                hatchpoly2.Vertexes.Add(new LwPolylineVertex(v14));
                hatchpoly2.Vertexes.Add(new LwPolylineVertex(v13));
                hatchpoly2.IsClosed = true;
                String[] htype2 = new String[100];
                Line[] hline2 = new Line[100];
                int hnumst2 = hatchpoly2.Explode().Count;  //记录爆炸后，线段有多少
                for (int i = 0; i < hnumst2; i++)
                {
                    htype2[i] = hatchpoly2.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                    if (htype2[i] == "Line")
                    {
                        hline2[i] = (Line)hatchpoly2.Explode()[i];
                    }
                }
                fun.hatchsuboflinew(dxf, htype2, hnumst2, 45, 0.5 * scale, hline2, contour, 0.5);
                LwPolyline hatchpoly3 = new LwPolyline();
                hatchpoly3.Vertexes.Add(new LwPolylineVertex(v12));
                hatchpoly3.Vertexes.Add(new LwPolylineVertex(v11));
                hatchpoly3.Vertexes.Add(new LwPolylineVertex(v10));
                hatchpoly3.Vertexes.Add(new LwPolylineVertex(v9));
                hatchpoly3.Vertexes.Add(new LwPolylineVertex(v1));
                hatchpoly3.Vertexes.Add(new LwPolylineVertex(v20));
                hatchpoly3.Vertexes.Add(new LwPolylineVertex(v19));
                hatchpoly3.Vertexes.Add(new LwPolylineVertex(v18));
                hatchpoly3.IsClosed = true;
                String[] htype3 = new String[100];
                Line[] hline3 = new Line[100];
                int hnumst3 = hatchpoly3.Explode().Count;  //记录爆炸后，线段有多少
                for (int i = 0; i < hnumst3; i++)
                {
                    htype3[i] = hatchpoly3.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                    if (htype3[i] == "Line")
                    {
                        hline3[i] = (Line)hatchpoly3.Explode()[i];
                    }
                }
                fun.hatchsubofline(dxf, htype3, hnumst3, 45, 5, hline3, hatching);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 1.0;
                double offset = 10;
                //线段尺寸标注
                //尺寸1
                LinearDimension dim1 = new LinearDimension(new Line(v5, v6), -offset, 0, dimensionStyle);
                dim1.UserText = "CW = " + Math.Round(cw / scale, 2);
                dxf.AddEntity(dim1);
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(v4, v5), -offset * 3, 270, dimensionStyle);
                dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸3
                LinearDimension dim3 = new LinearDimension(new Line(v6, v8), -offset - (v8.Y - v6.Y) / 2, 0, dimensionStyle);
                dim3.UserText = "HHUB = " + Math.Round(hhub / scale, 2);
                dxf.AddEntity(dim3);
                //尺寸4
                if (bcdpax != 0)
                {
                    LinearDimension dim4 = new LinearDimension(new Line(v5, v14), -offset - (v14.Y - v5.Y) / 2, 0, dimensionStyle);
                    dim4.UserText = "BCDPAX = " + Math.Round(bcdpax / scale, 2);
                    dxf.AddEntity(dim4);
                }
                //尺寸5
                LinearDimension dim5 = new LinearDimension(new Line(v5, v8), -offset * 2 - (v8.Y - v5.Y) / 2, 0, dimensionStyle);
                dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                dxf.AddEntity(dim5);
                //尺寸6
                LinearDimension dim6 = new LinearDimension(new Line(v20, v21), offset, 270, dimensionStyle);
                dim6.UserText = "DCON = " + Math.Round(dcon / scale, 2);
                dxf.AddEntity(dim6);
                //尺寸7
                LinearDimension dim7 = new LinearDimension(new Line(v1, v8), offset * 2, 270, dimensionStyle);
                dim7.UserText = "DHUB = " + Math.Round(dhub / scale, 2);
                dxf.AddEntity(dim7);
                //尺寸8
                LinearDimension dim8 = new LinearDimension(new Line(v14, v11), -offset * 2 - bcdpax, 270, dimensionStyle);
                dim8.UserText = "BCD = " + Math.Round(bcd / scale, 2);
                dxf.AddEntity(dim8);
                //尺寸9
                LinearDimension dim9 = new LinearDimension(new Line(v24, v17), -offset, 270, dimensionStyle);
                dim9.UserText = "DCCB = " + Math.Round(dccb / scale, 2);
                dxf.AddEntity(dim9);
                //尺寸10
                LinearDimension dim10 = new LinearDimension(new Line(v17, v18), offset + v4.Y - v17.Y, 0, dimensionStyle);
                dim10.UserText = "LCCB = " + Math.Round(lccb / scale, 2);
                dxf.AddEntity(dim10);
            }
            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(-210 - oal / 2, 148.5));
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            //定义格式，根据路径导出

            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }

        public static void SolidShellMill(Dictionary<string, Object> data)//套式立铣刀
        {
            DxfDocument dxf = new DxfDocument();
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);
            //作图
            //参数
            double soal = Convert.ToDouble(data["oal"]);
            double sdc = Convert.ToDouble(data["dc"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0)
            {
                if (sdc < 39 && soal < 90)
                {
                    scale = 4.0;
                }
                else if (sdc < 52 && soal < 120)
                {
                    scale = 3.0;
                }
                else if (sdc < 78 && soal < 180)
                {
                    scale = 2.0;
                }
                else if (sdc < 104 && soal < 240)
                {
                    scale = 1.5;
                }
                else if (sdc < 156 && soal < 360)
                {
                    scale = 1.0;
                }
                else if (sdc < 208 && soal < 480)
                {
                    scale = 0.75;
                }
                else
                {
                    scale = 0.5;
                }
            }
            double dc = Convert.ToDouble(data["dc"]) * scale;
            double dcon = Convert.ToDouble(data["dcon"]) * scale;
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double dhub = Convert.ToDouble(data["dhub"]) * scale;
            double cw = Convert.ToDouble(data["cw"]) * scale;
            double hhub = Convert.ToDouble(data["hhub"]) * scale;
            double bd = Convert.ToDouble(data["bd"]) * scale;
            double bcd = Convert.ToDouble(data["bcd"]) * scale;
            if (bcd == 0)
            {
                bcd = dc - 4 * scale;
            }
            double bcdpax = Convert.ToDouble(data["bcdpax"]) * scale;
            double dccb = Convert.ToDouble(data["dccb"]) * scale;
            double lccb = Convert.ToDouble(data["lccb"]) * scale;
            double isframe = Convert.ToDouble(data["isframe"]);
            string path = Convert.ToString(data["path"]);
            //坐标
            //主视图
            Vector2 v1 = new Vector2(0, dhub / 2);
            Vector2 v2 = new Vector2(-hhub, v1.Y);
            Vector2 v3 = new Vector2(v2.X, bd / 2);
            Vector2 v4 = new Vector2(-oal + cw, v3.Y);
            Vector2 v5 = new Vector2(v4.X, dc / 2);
            Vector2 v6 = new Vector2(-oal, v5.Y);
            Vector2 v7 = new Vector2(v6.X, -v6.Y);
            Vector2 v8 = new Vector2(v5.X, -v5.Y);
            Vector2 v9 = new Vector2(v4.X, -v4.Y);
            Vector2 v10 = new Vector2(v3.X, -v3.Y);
            Vector2 v11 = new Vector2(v2.X, -v2.Y);
            Vector2 v12 = new Vector2(v1.X, -v1.Y);
            Vector2 v13 = new Vector2(v5.X, bcd / 2);
            Vector2 v14 = new Vector2(v6.X + bcdpax, v13.Y);
            Vector2 v15 = new Vector2(v14.X, dccb / 2);
            Vector2 v16 = new Vector2(-oal + lccb, v15.Y);
            Vector2 v17 = new Vector2(v16.X, dcon / 2);
            Vector2 v18 = new Vector2(0, v17.Y);
            Vector2 v19 = new Vector2(v18.X, -v18.Y);
            Vector2 v20 = new Vector2(v17.X, -v17.Y);
            Vector2 v21 = new Vector2(v16.X, -v16.Y);
            Vector2 v22 = new Vector2(v15.X, -v15.Y);
            Vector2 v23 = new Vector2(v14.X, -v14.Y);
            Vector2 v24 = new Vector2(v13.X, -v13.Y);
            Vector2 v25 = new Vector2(v6.X, v15.Y);
            Vector2 v26 = new Vector2(v25.X, -v25.Y);
            Vector2 v27 = new Vector2(-oal - 2, 0);
            Vector2 v28 = new Vector2(2, 0);
            //线段
            //主视图
            Vector2[] Line1 = { v1, v2 };
            fun.drawBLine(dxf, Line1, 0.3, contour);
            Vector2[] Line2 = { v2, v3 };
            fun.drawBLine(dxf, Line2, 0.3, contour);
            Vector2[] Line3 = { v3, v4 };
            fun.drawBLine(dxf, Line3, 0.3, contour);
            Vector2[] Line4 = { v4, v5 };
            fun.drawBLine(dxf, Line4, 0.3, contour);
            Vector2[] Line5 = { v5, v6 };
            fun.drawBLine(dxf, Line5, 0.3, contour);
            Vector2[] Line6 = { v6, v7 };
            fun.drawBLine(dxf, Line6, 0.3, contour);
            Vector2[] Line7 = { v7, v8 };
            fun.drawBLine(dxf, Line7, 0.3, contour);
            Vector2[] Line8 = { v8, v9 };
            fun.drawBLine(dxf, Line8, 0.3, contour);
            Vector2[] Line9 = { v9, v10 };
            fun.drawBLine(dxf, Line9, 0.3, contour);
            Vector2[] Line10 = { v10, v11 };
            fun.drawBLine(dxf, Line10, 0.3, contour);
            Vector2[] Line11 = { v11, v12 };
            fun.drawBLine(dxf, Line11, 0.3, contour);
            Vector2[] Line12 = { v12, v1 };
            fun.drawBLine(dxf, Line12, 0.3, contour);
            Vector2[] Line13 = { v13, v14 };
            fun.drawBLine(dxf, Line13, 0.3, contour);
            Vector2[] Line14 = { v14, v15 };
            fun.drawBLine(dxf, Line14, 0.3, contour);
            Vector2[] Line15 = { v25, v16 };
            fun.drawBLine(dxf, Line15, 0.3, contour);
            Vector2[] Line16 = { v16, new Vector2(v16.X, 0) };
            fun.drawBLine(dxf, Line16, 0.3, contour);
            Vector2[] Line17 = { v17, v18 };
            fun.drawBLine(dxf, Line17, 0.3, contour);
            Vector2[] Line18 = { v19, v20 };
            fun.drawPlinetype(dxf, Line18, 0.15, refin, Linetype.Dashed);
            Vector2[] Line19 = { v21, new Vector2(v21.X, 0) };
            fun.drawPlinetype(dxf, Line19, 0.15, refin, Linetype.Dashed);
            Vector2[] Line20 = { v21, v22 };
            fun.drawPlinetype(dxf, Line20, 0.15, refin, Linetype.Dashed);
            Vector2[] Line21 = { v22, v26 };
            fun.drawBLine(dxf, Line21, 0.3, contour);
            Vector2[] Line22 = { v23, v22 };
            fun.drawBLine(dxf, Line22, 0.3, contour);
            Vector2[] Line23 = { v23, v24 };
            fun.drawBLine(dxf, Line23, 0.3, contour);
            Vector2[] Line24 = { v27, v28 };
            fun.drawPlinetype(dxf, Line24, 0.15, center, Linetype.Center);
            //填充
            LwPolyline hatchpoly1 = new LwPolyline();
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v5));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v6));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v25));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v15));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v14));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v13));
            hatchpoly1.IsClosed = true;
            String[] htype1 = new String[100];
            Line[] hline1 = new Line[100];
            int hnumst1 = hatchpoly1.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst1; i++)
            {
                htype1[i] = hatchpoly1.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype1[i] == "Line")
                {
                    hline1[i] = (Line)hatchpoly1.Explode()[i];
                }
            }
            fun.hatchsuboflinew(dxf, htype1, hnumst1, 45, 0.5 * scale, hline1, contour, 0.5);
            LwPolyline hatchpoly2 = new LwPolyline();
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v26));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v7));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v8));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v24));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v23));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v22));
            hatchpoly2.IsClosed = true;
            String[] htype2 = new String[100];
            Line[] hline2 = new Line[100];
            int hnumst2 = hatchpoly2.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst2; i++)
            {
                htype2[i] = hatchpoly2.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype2[i] == "Line")
                {
                    hline2[i] = (Line)hatchpoly2.Explode()[i];
                }
            }
            fun.hatchsuboflinew(dxf, htype2, hnumst2, 45, 0.5 * scale, hline2, contour, 0.5);
            LwPolyline hatchpoly3 = new LwPolyline();
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v1));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v2));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v3));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v4));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v13));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v14));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v15));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v16));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v17));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v18));
            hatchpoly3.IsClosed = true;
            String[] htype3 = new String[100];
            Line[] hline3 = new Line[100];
            int hnumst3 = hatchpoly3.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst3; i++)
            {
                htype3[i] = hatchpoly3.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype3[i] == "Line")
                {
                    hline3[i] = (Line)hatchpoly3.Explode()[i];
                }
            }
            fun.hatchsubofline(dxf, htype3, hnumst3, 45, 5, hline3, hatching);
            //标注样式
            //箭头样式
            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 0.2;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            //文本样式
            dimensionStyle.TextHeight = 1.0;
            double offset = 10;
            //线段尺寸标注
            //尺寸1
            LinearDimension dim1 = new LinearDimension(new Line(v7, v8), -offset * 2, 0, dimensionStyle);
            dim1.UserText = "CW = " + Math.Round(cw / scale, 2);
            dxf.AddEntity(dim1);
            //尺寸2
            LinearDimension dim2 = new LinearDimension(new Line(v8, v5), offset * 3 + oal - cw, 270, dimensionStyle);
            dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
            dxf.AddEntity(dim2);
            //尺寸3
            if (dhub != 0)
            {
                LinearDimension dim3 = new LinearDimension(new Line(v11, v12), -offset - (v12.Y - v8.Y), 0, dimensionStyle);
                dim3.UserText = "HHUB = " + Math.Round(hhub / scale, 2);
                dxf.AddEntity(dim3);
            }
            //尺寸4
            if (bcdpax != 0)
            {
                LinearDimension dim4 = new LinearDimension(new Line(v7, v23), -offset - (v23.Y - v7.Y) / 2, 0, dimensionStyle);
                dim4.UserText = "BCDPAX = " + Math.Round(bcdpax / scale, 2);
                dxf.AddEntity(dim4);
            }
            //尺寸5
            LinearDimension dim5 = new LinearDimension(new Line(v7, v12), -offset * 3 - (v12.Y - v7.Y) / 2, 0, dimensionStyle);
            dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
            dxf.AddEntity(dim5);
            //尺寸6
            LinearDimension dim6 = new LinearDimension(new Line(v17, v20), -offset - lccb, 270, dimensionStyle);
            dim6.UserText = "DCON = " + Math.Round(dcon / scale, 2);
            dxf.AddEntity(dim6);
            //尺寸7
            if (dhub != 0)
            {
                LinearDimension dim7 = new LinearDimension(new Line(v1, v12), offset, 270, dimensionStyle);
                dim7.UserText = "DHUB = " + Math.Round(dhub / scale, 2);
                dxf.AddEntity(dim7);
            }
            //尺寸8
            LinearDimension dim8 = new LinearDimension(new Line(v14, v23), -offset * 3 - bcdpax, 270, dimensionStyle);
            dim8.UserText = "BCD = " + Math.Round(bcd / scale, 2);
            dxf.AddEntity(dim8);
            //尺寸9
            LinearDimension dim9 = new LinearDimension(new Line(v25, v26), -offset * 2, 270, dimensionStyle);
            dim9.UserText = "DCCB = " + Math.Round(dccb / scale, 2);
            dxf.AddEntity(dim9);
            //尺寸10
            LinearDimension dim10 = new LinearDimension(new Line(v25, v16), offset + v6.Y - v25.Y, 0, dimensionStyle);
            dim10.UserText = "LCCB = " + Math.Round(lccb / scale, 2);
            dxf.AddEntity(dim10);
            //尺寸11
            if (bd != 0)
            {
                LinearDimension dim11 = new LinearDimension(new Line(v3, v10), offset * 2 + hhub, 270, dimensionStyle);
                dim11.UserText = "BD = " + Math.Round(bd / scale, 2);
                dxf.AddEntity(dim11);
            }
            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(-210 - oal / 2, 148.5));
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            //定义格式，根据路径导出

            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }

        public static void ThreadMillingCutter(Dictionary<string, Object> data)//螺纹铣刀
        {
            DxfDocument dxf = new DxfDocument();
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);

            //作图
            //参数
            double pi = Math.PI;
            double soal = Convert.ToDouble(data["oal"]);
            double sdc = Convert.ToDouble(data["dc"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0)
            {
                if (sdc < 39 && soal < 90)
                {
                    scale = 4.0;
                }
                else if (sdc < 52 && soal < 120)
                {
                    scale = 3.0;
                }
                else if (sdc < 78 && soal < 180)
                {
                    scale = 2.0;
                }
                else if (sdc < 104 && soal < 240)
                {
                    scale = 1.5;
                }
                else if (sdc < 156 && soal < 360)
                {
                    scale = 1.0;
                }
                else if (sdc < 208 && soal < 480)
                {
                    scale = 0.75;
                }
                else
                {
                    scale = 0.5;
                }
            }
            double dc = Convert.ToDouble(data["dc"]) * scale;
            double dcon = Convert.ToDouble(data["dcon"]) * scale;
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double dhub = Convert.ToDouble(data["dhub"]) * scale;
            double cw = Convert.ToDouble(data["cw"]) * scale;
            double hhub = Convert.ToDouble(data["hhub"]) * scale;
            double tp = Convert.ToDouble(data["tp"]) * scale;
            double bcd = dc - tp * Math.Sin(pi / 3) * 2;
            double dccb = Convert.ToDouble(data["dccb"]) * scale;
            double lccb = Convert.ToDouble(data["lccb"]) * scale;
            double isframe = Convert.ToDouble(data["isframe"]);
            string path = Convert.ToString(data["path"]);
            //坐标
            //主视图
            Vector2 v1 = new Vector2(0, dhub / 2);
            Vector2 v2 = new Vector2(-hhub, v1.Y);
            Vector2 v3 = new Vector2(v2.X, dc / 2);
            Vector2 v4 = new Vector2(-oal, dc / 2);
            Vector2 v5 = new Vector2(v4.X, -v4.Y);
            Vector2 v6 = new Vector2(v3.X, -v3.Y);
            Vector2 v7 = new Vector2(v2.X, -v2.Y);
            Vector2 v8 = new Vector2(v1.X, -v1.Y);
            Vector2 v9 = new Vector2(v8.X, -dcon / 2);
            Vector2 v10 = new Vector2(-oal + lccb, v9.Y);
            Vector2 v11 = new Vector2(v10.X, -dccb / 2);
            Vector2 v12 = new Vector2(-oal, v11.Y);
            Vector2 v13 = new Vector2(v12.X, -v12.Y);
            Vector2 v14 = new Vector2(v11.X, -v11.Y);
            Vector2 v15 = new Vector2(v10.X, -v10.Y);
            Vector2 v16 = new Vector2(v9.X, -v9.Y);
            Vector2 v17 = new Vector2(v3.X, bcd / 2);
            Vector2 v18 = new Vector2(v4.X, v17.Y);
            Vector2 v19 = new Vector2(v18.X, -v18.Y);
            Vector2 v20 = new Vector2(v17.X, -v17.Y);
            Vector2 v21 = new Vector2(-oal - 2, 0);
            Vector2 v22 = new Vector2(2, 0);
            //线段
            //主视图
            Vector2[] Line1 = { v1, v2 };
            fun.drawBLine(dxf, Line1, 0.3, contour);
            Vector2[] Line2 = { v2, v3 };
            fun.drawBLine(dxf, Line2, 0.3, contour);
            Vector2[] Line3 = { v3, v4 };
            fun.drawBLine(dxf, Line3, 0.3, contour);
            Vector2[] Line4 = { v4, v5 };
            fun.drawBLine(dxf, Line4, 0.3, contour);
            Vector2[] Line5 = { v5, v6 };
            fun.drawBLine(dxf, Line5, 0.3, contour);
            Vector2[] Line6 = { v6, v7 };
            fun.drawBLine(dxf, Line6, 0.3, contour);
            Vector2[] Line7 = { v7, v8 };
            fun.drawBLine(dxf, Line7, 0.3, contour);
            Vector2[] Line8 = { v8, v1 };
            fun.drawBLine(dxf, Line8, 0.3, contour);
            Vector2[] Line9 = { v9, v10 };
            fun.drawPlinetype(dxf, Line9, 0.15, refin, Linetype.Dashed);
            Vector2[] Line10 = { new Vector2(v10.X, 0), v11 };
            fun.drawPlinetype(dxf, Line10, 0.15, refin, Linetype.Dashed);
            Vector2[] Line11 = { v11, v12 };
            fun.drawPlinetype(dxf, Line11, 0.15, refin, Linetype.Dashed);
            Vector2[] Line12 = { v15, v16 };
            fun.drawBLine(dxf, Line12, 0.3, contour);
            Vector2[] Line13 = { v13, v14 };
            fun.drawBLine(dxf, Line13, 0.3, contour);
            Vector2[] Line14 = { v14, new Vector2(v14.X, 0) };
            fun.drawBLine(dxf, Line14, 0.3, contour);
            Vector2[] Line15 = { v7, new Vector2(v2.X, 0) };
            fun.drawBLine(dxf, Line15, 0.3, contour);
            Vector2[] Line16 = { v17, v18 };
            fun.drawBLine(dxf, Line16, 0.3, contour);
            Vector2[] Line17 = { v19, v20 };
            fun.drawPlinetype(dxf, Line17, 0.15, refin, Linetype.Continuous);
            Vector2[] Line18 = { v21, v22 };
            fun.drawPlinetype(dxf, Line18, 0.15, center, Linetype.Center);
            //填充
            LwPolyline hatchpoly3 = new LwPolyline();
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v1));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v2));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v17));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v18));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v13));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v14));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v15));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v16));
            hatchpoly3.IsClosed = true;
            String[] htype3 = new String[100];
            Line[] hline3 = new Line[100];
            int hnumst3 = hatchpoly3.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst3; i++)
            {
                htype3[i] = hatchpoly3.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype3[i] == "Line")
                {
                    hline3[i] = (Line)hatchpoly3.Explode()[i];
                }
            }
            fun.hatchsubofline(dxf, htype3, hnumst3, 45, 5, hline3, hatching);
            //标注样式
            //箭头样式
            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 0.2;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            //文本样式
            dimensionStyle.TextHeight = 1.0;
            double offset = 10;
            //线段尺寸标注
            //尺寸1
            LinearDimension dim1 = new LinearDimension(new Line(v5, v6), -offset, 0, dimensionStyle);
            dim1.UserText = "CW = " + Math.Round(cw / scale, 2);
            dxf.AddEntity(dim1);
            //尺寸2
            LinearDimension dim2 = new LinearDimension(new Line(v4, v5), -offset * 2, 270, dimensionStyle);
            dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
            dxf.AddEntity(dim2);
            //尺寸3
            if (dhub != 0)
            {
                LinearDimension dim3 = new LinearDimension(new Line(v6, v8), -offset - (v8.Y - v6.Y) / 2, 0, dimensionStyle);
                dim3.UserText = "HHUB = " + Math.Round(hhub / scale, 2);
                dxf.AddEntity(dim3);
            }
            //尺寸5
            LinearDimension dim5 = new LinearDimension(new Line(v5, v8), -offset * 2 - (v8.Y - v5.Y) / 2, 0, dimensionStyle);
            dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
            dxf.AddEntity(dim5);
            //尺寸6
            LinearDimension dim6 = new LinearDimension(new Line(v9, v16), offset, 270, dimensionStyle);
            dim6.UserText = "DCON = " + Math.Round(dcon / scale, 2);
            dxf.AddEntity(dim6);
            //尺寸7
            if (dhub != 0)
            {
                LinearDimension dim7 = new LinearDimension(new Line(v1, v8), offset * 2, 270, dimensionStyle);
                dim7.UserText = "DHUB = " + Math.Round(dhub / scale, 2);
                dxf.AddEntity(dim7);
            }
            //尺寸9
            LinearDimension dim9 = new LinearDimension(new Line(v12, v13), -offset, 270, dimensionStyle);
            dim9.UserText = "DCCB = " + Math.Round(dccb / scale, 2);
            dxf.AddEntity(dim9);
            //尺寸10
            LinearDimension dim10 = new LinearDimension(new Line(v13, v14), offset + v4.Y - v13.Y, 0, dimensionStyle);
            dim10.UserText = "LCCB = " + Math.Round(lccb / scale, 2);
            dxf.AddEntity(dim10);
            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(-210 - oal / 2, 148.5));
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            //定义格式，根据路径导出

            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }

        public static void SlottingCutter(Dictionary<string, Object> data)
        {
            DxfDocument dxf = new DxfDocument();
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);
            //作图
            //参数
            double soal = Convert.ToDouble(data["oal"]);
            double sdc = Convert.ToDouble(data["dc"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0)
            {
                if (sdc < 39 && soal < 90)
                {
                    scale = 4.0;
                }
                else if (sdc < 52 && soal < 120)
                {
                    scale = 3.0;
                }
                else if (sdc < 78 && soal < 180)
                {
                    scale = 2.0;
                }
                else if (sdc < 104 && soal < 240)
                {
                    scale = 1.5;
                }
                else if (sdc < 156 && soal < 360)
                {
                    scale = 1.0;
                }
                else if (sdc < 208 && soal < 480)
                {
                    scale = 0.75;
                }
                else
                {
                    scale = 0.5;
                }
            }
            double dc = Convert.ToDouble(data["dc"]) * scale;
            double dcon = Convert.ToDouble(data["dcon"]) * scale;
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double dhub = Convert.ToDouble(data["dhub"]) * scale;
            double cw = Convert.ToDouble(data["cw"]) * scale;
            double hhub = Convert.ToDouble(data["hhub"]) * scale;
            double bcd = Convert.ToDouble(data["bcd"]) * scale;
            if (bcd == 0)
            {
                bcd = dc - (dc - dhub) / 2;
            }
            double bcdpax = Convert.ToDouble(data["bcdpax"]) * scale;
            double kapr = 90;
            double cdx = (dc - dhub) / 2;
            double isframe = Convert.ToDouble(data["isframe"]);
            string path = Convert.ToString(data["path"]);
            //坐标
            //主视图
            Vector2 v1 = new Vector2(0, dhub / 2);
            Vector2 v2 = new Vector2(-hhub, v1.Y);
            Vector2 v3 = new Vector2(v2.X, dc / 2);
            Vector2 v4 = new Vector2(-oal + hhub, v3.Y);
            Vector2 v5 = new Vector2(v4.X, v2.Y);
            Vector2 v6 = new Vector2(-oal, v5.Y);
            Vector2 v7 = new Vector2(v6.X, -v6.Y);
            Vector2 v8 = new Vector2(v5.X, -v5.Y);
            Vector2 v9 = new Vector2(v4.X, -v4.Y);
            Vector2 v10 = new Vector2(v3.X, -v3.Y);
            Vector2 v11 = new Vector2(v2.X, -v2.Y);
            Vector2 v12 = new Vector2(v1.X, -v1.Y);
            Vector2 v13 = new Vector2(v3.X, bcd / 2);
            Vector2 v14 = new Vector2(v13.X - bcdpax, v13.Y);
            Vector2 v15 = new Vector2(v14.X, v3.Y - bcdpax);
            Vector2 v16 = new Vector2(v4.X + bcdpax, v15.Y);
            Vector2 v17 = new Vector2(v16.X, v14.Y);
            Vector2 v18 = new Vector2(v4.X, v17.Y);
            Vector2 v19 = new Vector2(v18.X, -v18.Y);
            Vector2 v20 = new Vector2(v17.X, -v17.Y);
            Vector2 v21 = new Vector2(v16.X, -v16.Y);
            Vector2 v22 = new Vector2(v15.X, -v15.Y);
            Vector2 v23 = new Vector2(v14.X, -v14.Y);
            Vector2 v24 = new Vector2(v13.X, -v13.Y);
            Vector2 v25 = new Vector2(v6.X, dcon / 2);
            Vector2 v26 = new Vector2(0, v25.Y);
            Vector2 v27 = new Vector2(v26.X, -v26.Y);
            Vector2 v28 = new Vector2(v25.X, -v25.Y);
            Vector2 v29 = new Vector2(-oal - 2, 0);
            Vector2 v30 = new Vector2(2, 0);
            //线段
            //主视图
            Vector2[] Line1 = { v1, v2 };
            fun.drawBLine(dxf, Line1, 0.3, contour);
            Vector2[] Line2 = { v2, v3 };
            fun.drawBLine(dxf, Line2, 0.3, contour);
            Vector2[] Line3 = { v3, v4 };
            fun.drawBLine(dxf, Line3, 0.3, contour);
            Vector2[] Line4 = { v4, v5 };
            fun.drawBLine(dxf, Line4, 0.3, contour);
            Vector2[] Line5 = { v5, v6 };
            fun.drawBLine(dxf, Line5, 0.3, contour);
            Vector2[] Line6 = { v6, v7 };
            fun.drawBLine(dxf, Line6, 0.3, contour);
            Vector2[] Line7 = { v7, v8 };
            fun.drawBLine(dxf, Line7, 0.3, contour);
            Vector2[] Line8 = { new Vector2(v8.X, 0), v9 };
            fun.drawBLine(dxf, Line8, 0.3, contour);
            Vector2[] Line9 = { v9, v10 };
            fun.drawBLine(dxf, Line9, 0.3, contour);
            Vector2[] Line10 = { v10, new Vector2(v10.X, 0) };
            fun.drawBLine(dxf, Line10, 0.3, contour);
            Vector2[] Line11 = { v11, v12 };
            fun.drawBLine(dxf, Line11, 0.3, contour);
            Vector2[] Line12 = { v12, v1 };
            fun.drawBLine(dxf, Line12, 0.3, contour);
            Vector2[] Line13 = { v13, v14 };
            fun.drawBLine(dxf, Line13, 0.3, contour);
            Vector2[] Line14 = { v14, v15 };
            fun.drawBLine(dxf, Line14, 0.3, contour);
            Vector2[] Line15 = { v15, v16 };
            fun.drawBLine(dxf, Line15, 0.3, contour);
            Vector2[] Line16 = { v16, v17 };
            fun.drawBLine(dxf, Line16, 0.3, contour);
            Vector2[] Line17 = { v17, v18 };
            fun.drawBLine(dxf, Line17, 0.3, contour);
            Vector2[] Line18 = { v19, v20 };
            fun.drawBLine(dxf, Line18, 0.3, contour);
            Vector2[] Line19 = { v20, v21 };
            fun.drawBLine(dxf, Line19, 0.3, contour);
            Vector2[] Line20 = { v21, v22 };
            fun.drawBLine(dxf, Line20, 0.3, contour);
            Vector2[] Line21 = { v22, v23 };
            fun.drawBLine(dxf, Line21, 0.3, contour);
            Vector2[] Line22 = { v23, v24 };
            fun.drawBLine(dxf, Line22, 0.3, contour);
            Vector2[] Line23 = { v25, v26 };
            fun.drawBLine(dxf, Line23, 0.3, contour);
            Vector2[] Line24 = { v27, v28 };
            fun.drawPlinetype(dxf, Line24, 0.15, refin, Linetype.Dashed);
            Vector2[] Line25 = { v29, v30 };
            fun.drawPlinetype(dxf, Line25, 0.15, center, Linetype.Center);
            Line Line26 = new Line(v10, new Vector2(v10.X + 10, v10.Y));
            Line Line27 = new Line(v10, new Vector2(v10.X, v10.Y - 10));
            Line26.Layer = dimensioning;
            Line27.Layer = dimensioning;
            dxf.AddEntity(Line26);
            dxf.AddEntity(Line27);
            //填充
            LwPolyline hatchpoly1 = new LwPolyline();
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v3));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v4));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v18));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v17));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v16));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v15));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v14));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v13));
            hatchpoly1.IsClosed = true;
            String[] htype1 = new String[100];
            Line[] hline1 = new Line[100];
            int hnumst1 = hatchpoly1.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst1; i++)
            {
                htype1[i] = hatchpoly1.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype1[i] == "Line")
                {
                    hline1[i] = (Line)hatchpoly1.Explode()[i];
                }
            }
            fun.hatchsuboflinew(dxf, htype1, hnumst1, 45, 0.5 * scale, hline1, contour, 0.5);
            LwPolyline hatchpoly2 = new LwPolyline();
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v9));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v10));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v24));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v23));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v22));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v21));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v20));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v19));
            hatchpoly2.IsClosed = true;
            String[] htype2 = new String[100];
            Line[] hline2 = new Line[100];
            int hnumst2 = hatchpoly2.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst2; i++)
            {
                htype2[i] = hatchpoly2.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype2[i] == "Line")
                {
                    hline2[i] = (Line)hatchpoly2.Explode()[i];
                }
            }
            fun.hatchsuboflinew(dxf, htype2, hnumst2, 45, 0.5 * scale, hline2, contour, 0.5);
            LwPolyline hatchpoly3 = new LwPolyline();
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v25));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v26));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v1));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v2));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v13));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v14));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v15));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v16));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v17));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v18));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v5));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v6));
            hatchpoly3.IsClosed = true;
            String[] htype3 = new String[100];
            Line[] hline3 = new Line[100];
            int hnumst3 = hatchpoly3.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst3; i++)
            {
                htype3[i] = hatchpoly3.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype3[i] == "Line")
                {
                    hline3[i] = (Line)hatchpoly3.Explode()[i];
                }
            }
            fun.hatchsubofline(dxf, htype3, hnumst3, 45, 5, hline3, hatching);
            //标注样式
            //箭头样式
            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 0.2;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            //文本样式
            dimensionStyle.TextHeight = 1.0;
            double offset = 10;
            //线段尺寸标注
            //尺寸1
            LinearDimension dim1 = new LinearDimension(new Line(v3, v4), offset, 0, dimensionStyle);
            dim1.UserText = "CW = " + Math.Round(cw / scale, 2);
            dxf.AddEntity(dim1);
            //尺寸2
            LinearDimension dim2 = new LinearDimension(new Line(v4, v9), -offset * 3 - hhub, 270, dimensionStyle);
            dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
            dxf.AddEntity(dim2);
            //尺寸3
            if (dhub != 0)
            {
                LinearDimension dim3 = new LinearDimension(new Line(v7, v9), -offset - (v7.Y - v9.Y) / 2, 0, dimensionStyle);
                dim3.UserText = "HHUB = " + Math.Round(hhub / scale, 2);
                dxf.AddEntity(dim3);
            }
            //尺寸4
            if (bcdpax != 0)
            {
                LinearDimension dim4 = new LinearDimension(new Line(v22, v10), -offset - (v22.Y - v10.Y) / 2, 0, dimensionStyle);
                dim4.UserText = "BCDPAX = " + Math.Round(bcdpax / scale, 2);
                dxf.AddEntity(dim4);
            }
            //尺寸5
            LinearDimension dim5 = new LinearDimension(new Line(v6, v1), offset * 2 + v4.Y - v6.Y, 0, dimensionStyle);
            dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
            dxf.AddEntity(dim5);
            //尺寸6
            LinearDimension dim6 = new LinearDimension(new Line(v26, v27), offset, 270, dimensionStyle);
            dim6.UserText = "DCON = " + Math.Round(dcon / scale, 2);
            dxf.AddEntity(dim6);
            //尺寸7
            if (dhub != 0)
            {
                LinearDimension dim7 = new LinearDimension(new Line(v6, v7), -offset, 270, dimensionStyle);
                dim7.UserText = "DHUB = " + Math.Round(dhub / scale, 2);
                dxf.AddEntity(dim7);
            }
            //尺寸8
            LinearDimension dim8 = new LinearDimension(new Line(v18, v19), -offset * 2 - hhub, 270, dimensionStyle);
            dim8.UserText = "BCD = " + Math.Round(bcd / scale, 2);
            dxf.AddEntity(dim8);
            //尺寸9
            LinearDimension dim9 = new LinearDimension(new Line(v3, v1), offset - v3.X / 2, 270, dimensionStyle);
            dim9.UserText = "CDX = " + Math.Round(cdx / scale, 2);
            dxf.AddEntity(dim9);
            //尺寸10
            Angular2LineDimension angdim1 = new Angular2LineDimension(Line26, Line27, offset, dimensionStyle);
            angdim1.UserText = "KAPR = " + Math.Round(kapr, 2) + "°";
            dxf.AddEntity(angdim1);
            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(-210 - oal / 2, 148.5));
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            //定义格式，根据路径导出

            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }

        public static void PointedProfileSlottingCutter(Dictionary<string, Object> data)  //对称双角铣刀
        {
            DxfDocument dxf = new DxfDocument();
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);
            //作图
            //参数
            double pi = Math.PI;
            double soal = Convert.ToDouble(data["oal"]);
            double sdc = Convert.ToDouble(data["dc"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0)
            {
                if (sdc < 39 && soal < 90)
                {
                    scale = 4.0;
                }
                else if (sdc < 52 && soal < 120)
                {
                    scale = 3.0;
                }
                else if (sdc < 78 && soal < 180)
                {
                    scale = 2.0;
                }
                else if (sdc < 104 && soal < 240)
                {
                    scale = 1.5;
                }
                else if (sdc < 156 && soal < 360)
                {
                    scale = 1.0;
                }
                else if (sdc < 208 && soal < 480)
                {
                    scale = 0.75;
                }
                else
                {
                    scale = 0.5;
                }
            }
            double dc = Convert.ToDouble(data["dc"]) * scale;
            double dcon = Convert.ToDouble(data["dcon"]) * scale;
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double dhub = Convert.ToDouble(data["dhub"]) * scale;
            double cw = Convert.ToDouble(data["cw"]) * scale;
            double hhub = Convert.ToDouble(data["hhub"]) * scale;
            double bcd = Convert.ToDouble(data["bcd"]) * scale;
            if (bcd == 0)
            {
                bcd = dc - 4 * scale;
            }
            double pna = Convert.ToDouble(data["pna"]) * pi / 180;
            double kapr = (pi - pna) / 2;
            double prfrad = Convert.ToDouble(data["prfrad"]) * scale;
            double cdx = (dc - dhub) / 2;
            double isframe = Convert.ToDouble(data["isframe"]);
            string path = Convert.ToString(data["path"]);
            //坐标
            //主视图
            Vector2 v1 = new Vector2(0, dhub / 2);
            Vector2 v2 = new Vector2(-hhub, v1.Y);
            Vector2 v3 = new Vector2(v2.X, dc / 2 - cw / 2 * Math.Tan(kapr));
            Vector2 v4 = new Vector2(-oal / 2, dc / 2 - prfrad);
            Vector2 v5 = new Vector2(-oal + hhub, v3.Y);
            Vector2 v6 = new Vector2(v5.X, v2.Y);
            Vector2 v7 = new Vector2(-oal, v6.Y);
            Vector2 v8 = new Vector2(v7.X, -v7.Y);
            Vector2 v9 = new Vector2(v6.X, -v6.Y);
            Vector2 v10 = new Vector2(v5.X, -v5.Y);
            Vector2 v11 = new Vector2(v4.X, -v4.Y);
            Vector2 v12 = new Vector2(v3.X, -v3.Y);
            Vector2 v13 = new Vector2(v2.X, -v2.Y);
            Vector2 v14 = new Vector2(v1.X, -v1.Y);
            Vector2 v15 = new Vector2(v3.X, v3.Y - (dc - bcd) / 2);
            Vector2 v16 = new Vector2(v4.X, v4.Y - (dc - bcd) / 2);
            Vector2 v17 = new Vector2(v5.X, v15.Y);
            Vector2 v18 = new Vector2(v17.X, -v17.Y);
            Vector2 v19 = new Vector2(v16.X, -v16.Y);
            Vector2 v20 = new Vector2(v15.X, -v15.Y);
            Vector2 v21 = new Vector2(0, -dcon / 2);
            Vector2 v22 = new Vector2(-oal, v21.Y);
            Vector2 v23 = new Vector2(v22.X, -v22.Y);
            Vector2 v24 = new Vector2(v21.X, -v21.Y);
            Vector2 v25 = new Vector2(-oal - 2, 0);
            Vector2 v26 = new Vector2(2, 0);
            Vector2 v30 = new Vector2(v11.X - prfrad * Math.Sin((pi - pna) / 2), v11.Y - prfrad * Math.Cos((pi - pna) / 2));
            Vector2 v31 = new Vector2(v11.X + prfrad * Math.Sin((pi - pna) / 2), v11.Y - prfrad * Math.Cos((pi - pna) / 2));
            Vector2 v32 = new Vector2(v19.X - prfrad * Math.Sin((pi - pna) / 2), v19.Y - prfrad * Math.Cos((pi - pna) / 2));
            Vector2 v33 = new Vector2(v19.X + prfrad * Math.Sin((pi - pna) / 2), v19.Y - prfrad * Math.Cos((pi - pna) / 2));
            Vector2 v34 = new Vector2(v30.X, -v30.Y);
            Vector2 v35 = new Vector2(v31.X, -v31.Y);
            Vector2 v36 = new Vector2(v32.X, -v32.Y);
            Vector2 v37 = new Vector2(v33.X, -v33.Y);
            Vector2 v38 = new Vector2(v11.X, v11.Y - prfrad / Math.Cos(kapr));
            Vector2 v27 = new Vector2(v10.X, 2 * v38.Y - v10.Y);
            Vector2 v28 = new Vector2(v12.X, 2 * v38.Y - v12.Y);
            Vector2 v29 = new Vector2(v12.X, v38.Y);
            //线段
            //主视图
            Vector2[] Line1 = { v1, v2 };
            fun.drawBLine(dxf, Line1, 0.3, contour);
            Vector2[] Line2 = { new Vector2(v3.X, 0), v3 };
            fun.drawBLine(dxf, Line2, 0.3, contour);
            Vector2[] Line3 = { v3, v35 };
            fun.drawBLine(dxf, Line3, 0.3, contour);
            Vector2[] Line4 = { v34, v5 };
            fun.drawBLine(dxf, Line4, 0.3, contour);
            Vector2[] Line5 = { v5, new Vector2(v5.X, 0) };
            fun.drawBLine(dxf, Line5, 0.3, contour);
            Vector2[] Line6 = { v6, v7 };
            fun.drawBLine(dxf, Line6, 0.3, contour);
            Vector2[] Line7 = { v7, v8 };
            fun.drawBLine(dxf, Line7, 0.3, contour);
            Vector2[] Line8 = { v8, v9 };
            fun.drawBLine(dxf, Line8, 0.3, contour);
            Vector2[] Line9 = { v9, v10 };
            fun.drawBLine(dxf, Line9, 0.3, contour);
            Vector2[] Line10 = { v10, v30 };
            fun.drawBLine(dxf, Line10, 0.3, contour);
            Vector2[] Line11 = { v31, v12 };
            fun.drawBLine(dxf, Line11, 0.3, contour);
            Vector2[] Line12 = { v12, v13 };
            fun.drawBLine(dxf, Line12, 0.3, contour);
            Vector2[] Line13 = { v13, v14 };
            fun.drawBLine(dxf, Line13, 0.3, contour);
            Vector2[] Line14 = { v14, v1 };
            fun.drawBLine(dxf, Line14, 0.3, contour);
            Vector2[] Line15 = { v15, v37 };
            fun.drawBLine(dxf, Line15, 0.3, contour);
            Vector2[] Line16 = { v36, v17 };
            fun.drawBLine(dxf, Line16, 0.3, contour);
            Vector2[] Line17 = { v18, v32 };
            fun.drawBLine(dxf, Line17, 0.3, contour);
            Vector2[] Line18 = { v33, v20 };
            fun.drawBLine(dxf, Line18, 0.3, contour);
            Vector2[] Line19 = { v21, v22 };
            fun.drawBLine(dxf, Line19, 0.3, contour);
            Vector2[] Line20 = { v23, v24 };
            fun.drawPlinetype(dxf, Line20, 0.15, refin, Linetype.Dashed);
            Vector2[] Line21 = { v25, v26 };
            fun.drawPlinetype(dxf, Line21, 0.15, center, Linetype.Center);
            Line Line22 = new Line(v38, v27);
            Line Line23 = new Line(v38, v28);
            Line Line24 = new Line(v38, v29);
            Line22.Layer = dimensioning;
            Line23.Layer = dimensioning;
            Line24.Layer = dimensioning;
            dxf.AddEntity(Line22);
            dxf.AddEntity(Line23);
            dxf.AddEntity(Line24);
            LwPolyline Arc25 = new LwPolyline();
            Arc25.Vertexes.Add(new LwPolylineVertex(v30));
            Arc25.Vertexes.Add(new LwPolylineVertex(v31));
            Arc25.Vertexes[0].Bulge = (1 - Math.Cos((pi - pna) / 2)) / Math.Sin((pi - pna) / 2);
            fun.PolyFill(dxf, Arc25, 0.3, contour);
            LwPolyline Arc26 = new LwPolyline();
            Arc26.Vertexes.Add(new LwPolylineVertex(v32));
            Arc26.Vertexes.Add(new LwPolylineVertex(v33));
            Arc26.Vertexes[0].Bulge = (1 - Math.Cos((pi - pna) / 2)) / Math.Sin((pi - pna) / 2);
            fun.PolyFill(dxf, Arc26, 0.3, contour);
            LwPolyline Arc27 = new LwPolyline();
            Arc27.Vertexes.Add(new LwPolylineVertex(v35));
            Arc27.Vertexes.Add(new LwPolylineVertex(v34));
            Arc27.Vertexes[0].Bulge = (1 - Math.Cos((pi - pna) / 2)) / Math.Sin((pi - pna) / 2);
            fun.PolyFill(dxf, Arc27, 0.3, contour);
            LwPolyline Arc28 = new LwPolyline();
            Arc28.Vertexes.Add(new LwPolylineVertex(v37));
            Arc28.Vertexes.Add(new LwPolylineVertex(v36));
            Arc28.Vertexes[0].Bulge = (1 - Math.Cos((pi - pna) / 2)) / Math.Sin((pi - pna) / 2);
            fun.PolyFill(dxf, Arc28, 0.3, contour);
            Arc arc29 = new Arc(v11, prfrad, (-pi + pna / 2) / pi * 180, -pna / 2 / pi * 180);
            //填充
            LwPolyline hatchpoly1 = new LwPolyline();
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v35));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v34));
            hatchpoly1.Vertexes[0].Bulge = (1 - Math.Cos((pi - pna) / 2)) / Math.Sin((pi - pna) / 2);
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v5));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v17));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v36));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v37));
            hatchpoly1.Vertexes[4].Bulge = -(1 - Math.Cos((pi - pna) / 2)) / Math.Sin((pi - pna) / 2);
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v15));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v3));
            hatchpoly1.IsClosed = true;
            String[] htype1 = new String[100];
            Line[] hline1 = new Line[100];
            Arc[] harc1 = new Arc[100];
            int hnumst1 = hatchpoly1.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst1; i++)
            {
                htype1[i] = hatchpoly1.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype1[i] == "Line")
                {
                    hline1[i] = (Line)hatchpoly1.Explode()[i];
                }
                if (htype1[i] == "Arc")
                {
                    harc1[i] = (Arc)hatchpoly1.Explode()[i];
                }
            }
            fun.hatchsub1(dxf, htype1, hnumst1, 45, 0.25, hline1, harc1, contour);
            LwPolyline hatchpoly2 = new LwPolyline();
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v30));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v31));
            hatchpoly2.Vertexes[0].Bulge = (1 - Math.Cos((pi - pna) / 2)) / Math.Sin((pi - pna) / 2);
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v12));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v20));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v33));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v32));
            hatchpoly2.Vertexes[4].Bulge = -(1 - Math.Cos((pi - pna) / 2)) / Math.Sin((pi - pna) / 2);
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v18));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v10));
            hatchpoly2.IsClosed = true;
            String[] htype2 = new String[100];
            Line[] hline2 = new Line[100];
            Arc[] harc2 = new Arc[100];
            int hnumst2 = hatchpoly2.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst2; i++)
            {
                htype2[i] = hatchpoly2.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype2[i] == "Line")
                {
                    hline2[i] = (Line)hatchpoly2.Explode()[i];
                }
                if (htype2[i] == "Arc")
                {
                    harc2[i] = (Arc)hatchpoly2.Explode()[i];
                }
            }
            fun.hatchsub1(dxf, htype2, hnumst2, 45, 0.25, hline2, harc2, contour);
            LwPolyline hatchpoly3 = new LwPolyline();
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v18));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v32));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v33));
            hatchpoly3.Vertexes[1].Bulge = (1 - Math.Cos((pi - pna) / 2)) / Math.Sin((pi - pna) / 2);
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v20));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v13));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v14));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v21));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v22));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v8));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v9));
            hatchpoly3.IsClosed = true;
            String[] htype3 = new String[100];
            Line[] hline3 = new Line[100];
            Arc[] harc3 = new Arc[100];
            int hnumst3 = hatchpoly3.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst3; i++)
            {
                htype3[i] = hatchpoly3.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype3[i] == "Line")
                {
                    hline3[i] = (Line)hatchpoly3.Explode()[i];
                }
                if (htype3[i] == "Arc")
                {
                    harc3[i] = (Arc)hatchpoly3.Explode()[i];
                }
            }
            fun.hatchsub1(dxf, htype3, hnumst3, 45, 5, hline3, harc3, hatching);
            //标注样式
            //箭头样式
            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 0.2;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            //文本样式
            dimensionStyle.TextHeight = 1.0;
            double offset = 10;
            //线段尺寸标注
            //尺寸1
            LinearDimension dim1 = new LinearDimension(new Line(v3, v5), offset + v4.Y - v3.Y, 0, dimensionStyle);
            dim1.UserText = "CW = " + Math.Round(cw / scale, 2);
            dxf.AddEntity(dim1);
            //尺寸2
            LinearDimension dim2 = new LinearDimension(new Line(new Vector2(v4.X, v4.Y + prfrad), new Vector2(v11.X, v11.Y - prfrad)), -offset * 3 - v4.X + v7.X, 270, dimensionStyle);
            dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
            dxf.AddEntity(dim2);
            //尺寸3
            if (dhub != 0)
            {
                LinearDimension dim3 = new LinearDimension(new Line(v7, v5), offset + (v5.Y - v7.Y) / 2 + v4.Y - v5.Y, 0, dimensionStyle);
                dim3.UserText = "HHUB = " + Math.Round(hhub / scale, 2);
                dxf.AddEntity(dim3);
            }
            //尺寸4
            LinearDimension dim4 = new LinearDimension(new Line(new Vector2(v16.X, v16.Y + prfrad), new Vector2(v19.X, v19.Y - prfrad)), -offset * 2 - v4.X + v7.X, 0, dimensionStyle);
            dim4.UserText = "BCD = " + Math.Round(bcd / scale, 2);
            dxf.AddEntity(dim4);
            //尺寸5
            LinearDimension dim5 = new LinearDimension(new Line(v7, v1), offset * 2 + v4.Y - v1.Y, 0, dimensionStyle);
            dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
            dxf.AddEntity(dim5);
            //尺寸6
            LinearDimension dim6 = new LinearDimension(new Line(v21, v24), offset, 270, dimensionStyle);
            dim6.UserText = "DCON = " + Math.Round(dcon / scale, 2);
            dxf.AddEntity(dim6);
            //尺寸7
            if (dhub != 0)
            {
                LinearDimension dim7 = new LinearDimension(new Line(v7, v8), -offset, 270, dimensionStyle);
                dim7.UserText = "DHUB = " + Math.Round(dhub / scale, 2);
                dxf.AddEntity(dim7);
            }
            //尺寸8
            RadialDimension dimrad8 = new RadialDimension(arc29, -(pna + kapr) / pi * 180 - 10, offset, dimensionStyle);//DimensionStyle.Default);
            dimrad8.UserText = "PRFRAD = " + Math.Round(prfrad / scale, 2);
            dxf.AddEntity(dimrad8);
            //尺寸9
            LinearDimension dim9 = new LinearDimension(new Line(v1, new Vector2(v4.X, v4.Y + prfrad)), offset - v4.X / 2, 270, dimensionStyle);
            dim9.UserText = "CDX = " + Math.Round(cdx / scale, 2);
            dxf.AddEntity(dim9);
            //尺寸10
            Angular2LineDimension angdim1 = new Angular2LineDimension(new Line(v38, v12), new Line(v38, v29), v12.X - v11.X + offset, dimensionStyle);
            angdim1.UserText = "KAPR = " + Math.Round(kapr / pi * 180, 2) + "°";
            dxf.AddEntity(angdim1);
            //尺寸11
            Angular2LineDimension angdim2 = new Angular2LineDimension(new Line(v38, v27), new Line(v38, v28), offset, dimensionStyle);
            angdim2.UserText = "PNA = " + Math.Round(pna / pi * 180, 2) + "°";
            dxf.AddEntity(angdim2);
            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(-210 - oal / 2, 148.5));
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            //定义格式，根据路径导出

            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }

        public static void SolidFlattedProfileSlottingCutter(Dictionary<string, Object> data)  //平顶对称双角铣刀
        {
            DxfDocument dxf = new DxfDocument();
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);
            //作图
            //参数
            double pi = Math.PI;
            double soal = Convert.ToDouble(data["oal"]);
            double sdc = Convert.ToDouble(data["dc"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0)
            {
                if (sdc < 39 && soal < 90)
                {
                    scale = 4.0;
                }
                else if (sdc < 52 && soal < 120)
                {
                    scale = 3.0;
                }
                else if (sdc < 78 && soal < 180)
                {
                    scale = 2.0;
                }
                else if (sdc < 104 && soal < 240)
                {
                    scale = 1.5;
                }
                else if (sdc < 156 && soal < 360)
                {
                    scale = 1.0;
                }
                else if (sdc < 208 && soal < 480)
                {
                    scale = 0.75;
                }
                else
                {
                    scale = 0.5;
                }
            }
            double dc = Convert.ToDouble(data["dc"]) * scale;
            double dcon = Convert.ToDouble(data["dcon"]) * scale;
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double dhub = Convert.ToDouble(data["dhub"]) * scale;
            double cw = Convert.ToDouble(data["cw"]) * scale;
            double hhub = Convert.ToDouble(data["hhub"]) * scale;
            double lcc = Convert.ToDouble(data["lcc"]) * scale;
            double fw = Convert.ToDouble(data["fw"]) * scale;
            double bcd = Convert.ToDouble(data["bcd"]) * scale;
            if (bcd == 0)
            {
                bcd = dc - 4 * scale;
            }
            double pna = Convert.ToDouble(data["pna"]) * pi / 180;
            double kapr = Convert.ToDouble(data["kapr"]) * pi / 180;
            double cdx = (dc - dhub) / 2;
            double isframe = Convert.ToDouble(data["isframe"]);
            string path = Convert.ToString(data["path"]);
            //坐标
            //主视图
            Vector2 v1 = new Vector2(0, dhub / 2);
            Vector2 v2 = new Vector2(-hhub, v1.Y);
            Vector2 v3 = new Vector2(v2.X, dc / 2 - (cw - lcc - fw) * Math.Tan(kapr));
            Vector2 v4 = new Vector2(-oal + hhub + lcc + fw, dc / 2);
            Vector2 v5 = new Vector2(-oal + hhub + lcc, v4.Y);
            Vector2 v6 = new Vector2(-oal + hhub, v5.Y - lcc * Math.Tan(pi - kapr - pna));
            Vector2 v7 = new Vector2(v6.X, v2.Y);
            Vector2 v8 = new Vector2(-oal, v1.Y);
            Vector2 v9 = new Vector2(v8.X, -v8.Y);
            Vector2 v10 = new Vector2(v7.X, -v7.Y);
            Vector2 v11 = new Vector2(v6.X, -v6.Y);
            Vector2 v12 = new Vector2(v5.X, -v5.Y);
            Vector2 v13 = new Vector2(v4.X, -v4.Y);
            Vector2 v14 = new Vector2(v3.X, -v3.Y);
            Vector2 v15 = new Vector2(v2.X, -v2.Y);
            Vector2 v16 = new Vector2(v1.X, -v1.Y);
            Vector2 v17 = new Vector2(v3.X, v3.Y - (dc - bcd) / 2 / Math.Cos(kapr));
            Vector2 v18 = new Vector2(v4.X - (dc - bcd) / 2 / Math.Tan((pi - kapr) / 2), bcd / 2);
            Vector2 v19 = new Vector2(v5.X + (dc - bcd) / 2 / Math.Tan((pna + kapr) / 2), v18.Y);
            Vector2 v20 = new Vector2(v6.X, v6.Y - (dc - bcd) / 2 / Math.Cos(pi - kapr - pna));
            Vector2 v21 = new Vector2(v20.X, -v20.Y);
            Vector2 v22 = new Vector2(v19.X, -v19.Y);
            Vector2 v23 = new Vector2(v18.X, -v18.Y);
            Vector2 v24 = new Vector2(v17.X, -v17.Y);
            Vector2 v25 = new Vector2(-oal - 2, 0);
            Vector2 v26 = new Vector2(2, 0);
            Vector2 v27 = new Vector2(v8.X, dcon / 2);
            Vector2 v28 = new Vector2(v1.X, v27.Y);
            Vector2 v29 = new Vector2(v27.X, -dcon / 2);
            Vector2 v30 = new Vector2(v28.X, v29.Y);
            Vector2 v31 = new Vector2(v14.X - (v14.Y - v11.Y + cw * Math.Tan(pi - kapr - pna)) / (Math.Tan(pi - kapr - pna) + Math.Tan(kapr)), v14.Y - (v14.Y - v11.Y + cw * Math.Tan(pi - kapr - pna)) * Math.Tan(kapr) / (Math.Tan(pi - kapr - pna) + Math.Tan(kapr)));
            Vector2 v32 = new Vector2(v12.X, v31.Y * 2 - v12.Y);
            Vector2 v33 = new Vector2(v13.X, v31.Y * 2 - v13.Y);
            Vector2 v34 = new Vector2(v14.X, v13.Y);
            //线段
            //主视图
            Vector2[] Line1 = { v1, v2 };
            fun.drawBLine(dxf, Line1, 0.3, contour);
            Vector2[] Line2 = { new Vector2(v3.X, 0), v3 };
            fun.drawBLine(dxf, Line2, 0.3, contour);
            Vector2[] Line3 = { v3, v4 };
            fun.drawBLine(dxf, Line3, 0.3, contour);
            Vector2[] Line4 = { v4, v5 };
            fun.drawBLine(dxf, Line4, 0.3, contour);
            Vector2[] Line5 = { v5, v6 };
            fun.drawBLine(dxf, Line5, 0.3, contour);
            Vector2[] Line6 = { v6, new Vector2(v6.X, 0) };
            fun.drawBLine(dxf, Line6, 0.3, contour);
            Vector2[] Line7 = { v7, v8 };
            fun.drawBLine(dxf, Line7, 0.3, contour);
            Vector2[] Line8 = { v8, v9 };
            fun.drawBLine(dxf, Line8, 0.3, contour);
            Vector2[] Line9 = { v9, v10 };
            fun.drawBLine(dxf, Line9, 0.3, contour);
            Vector2[] Line10 = { v10, v11 };
            fun.drawBLine(dxf, Line10, 0.3, contour);
            Vector2[] Line11 = { v11, v12 };
            fun.drawBLine(dxf, Line11, 0.3, contour);
            Vector2[] Line12 = { v12, v13 };
            fun.drawBLine(dxf, Line12, 0.3, contour);
            Vector2[] Line13 = { v13, v14 };
            fun.drawBLine(dxf, Line13, 0.3, contour);
            Vector2[] Line14 = { v14, v15 };
            fun.drawBLine(dxf, Line14, 0.3, contour);
            Vector2[] Line15 = { v15, v16 };
            fun.drawBLine(dxf, Line15, 0.3, contour);
            Vector2[] Line16 = { v16, v1 };
            fun.drawBLine(dxf, Line16, 0.3, contour);
            Vector2[] Line17 = { v17, v18 };
            fun.drawBLine(dxf, Line17, 0.3, contour);
            Vector2[] Line18 = { v18, v19 };
            fun.drawBLine(dxf, Line18, 0.3, contour);
            Vector2[] Line19 = { v19, v20 };
            fun.drawBLine(dxf, Line19, 0.3, contour);
            Vector2[] Line20 = { v21, v22 };
            fun.drawBLine(dxf, Line20, 0.3, contour);
            Vector2[] Line21 = { v22, v23 };
            fun.drawBLine(dxf, Line21, 0.3, contour);
            Vector2[] Line22 = { v23, v24 };
            fun.drawBLine(dxf, Line22, 0.3, contour);
            Vector2[] Line23 = { v27, v28 };
            fun.drawPlinetype(dxf, Line23, 0.15, refin, Linetype.Dashed);
            Vector2[] Line24 = { v29, v30 };
            fun.drawBLine(dxf, Line24, 0.3, contour);
            Vector2[] Line25 = { v25, v26 };
            fun.drawPlinetype(dxf, Line25, 0.15, center, Linetype.Center);
            Line Line26 = new Line(v13, v32);
            Line Line27 = new Line(v12, v33);
            Line Line28 = new Line(v13, v34);
            Line26.Layer = dimensioning;
            Line27.Layer = dimensioning;
            Line28.Layer = dimensioning;
            dxf.AddEntity(Line26);
            dxf.AddEntity(Line27);
            dxf.AddEntity(Line28);
            //填充
            LwPolyline hatchpoly1 = new LwPolyline();
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v11));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v12));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v13));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v14));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v24));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v23));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v22));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v21));
            hatchpoly1.IsClosed = true;
            String[] htype1 = new String[100];
            Line[] hline1 = new Line[100];
            int hnumst1 = hatchpoly1.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst1; i++)
            {
                htype1[i] = hatchpoly1.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype1[i] == "Line")
                {
                    hline1[i] = (Line)hatchpoly1.Explode()[i];
                }
            }
            fun.hatchsuboflinew(dxf, htype1, hnumst1, 45, 0.5 * scale, hline1, contour, 0.5);
            LwPolyline hatchpoly2 = new LwPolyline();
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v3));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v4));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v5));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v6));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v20));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v19));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v18));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v17));
            hatchpoly2.IsClosed = true;
            String[] htype2 = new String[100];
            Line[] hline2 = new Line[100];
            int hnumst2 = hatchpoly2.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst2; i++)
            {
                htype2[i] = hatchpoly2.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype2[i] == "Line")
                {
                    hline2[i] = (Line)hatchpoly2.Explode()[i];
                }
            }
            fun.hatchsuboflinew(dxf, htype2, hnumst2, 45, 0.5 * scale, hline2, contour, 0.5);
            LwPolyline hatchpoly3 = new LwPolyline();
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v9));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v10));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v21));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v22));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v23));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v24));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v15));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v16));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v30));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v29));
            hatchpoly3.IsClosed = true;
            String[] htype3 = new String[100];
            Line[] hline3 = new Line[100];
            int hnumst3 = hatchpoly3.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst3; i++)
            {
                htype3[i] = hatchpoly3.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype3[i] == "Line")
                {
                    hline3[i] = (Line)hatchpoly3.Explode()[i];
                }
            }
            fun.hatchsubofline(dxf, htype3, hnumst3, 45, 5, hline3, hatching);
            //标注样式
            //箭头样式
            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 0.2;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            //文本样式
            dimensionStyle.TextHeight = 1.0;
            double offset = 10;
            //线段尺寸标注
            //尺寸1
            LinearDimension dim1 = new LinearDimension(new Line(v3, v6), offset * 2 + v4.Y - (v3.Y + v6.Y) / 2, 0, dimensionStyle);
            dim1.UserText = "CW = " + Math.Round(cw / scale, 2);
            dxf.AddEntity(dim1);
            //尺寸2
            LinearDimension dim2 = new LinearDimension(new Line(v5, v12), -offset * 3 - (v5.X + v12.X) / 2 + v9.X, 270, dimensionStyle);
            dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
            dxf.AddEntity(dim2);
            //尺寸3
            if (dhub != 0)
            {
                LinearDimension dim3 = new LinearDimension(new Line(v9, v10), -offset - v9.Y + v12.Y, 0, dimensionStyle);
                dim3.UserText = "HHUB = " + Math.Round(hhub / scale, 2);
                dxf.AddEntity(dim3);
            }
            //尺寸4
            LinearDimension dim4 = new LinearDimension(new Line(v19, v22), -offset * 2 - v19.X + v9.X, 270, dimensionStyle);
            dim4.UserText = "BCD = " + Math.Round(bcd / scale, 2);
            dxf.AddEntity(dim4);
            //尺寸5
            LinearDimension dim5 = new LinearDimension(new Line(v1, v8), offset * 3 + v4.Y - v1.Y, 0, dimensionStyle);
            dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
            dxf.AddEntity(dim5);
            //尺寸6
            LinearDimension dim6 = new LinearDimension(new Line(v28, v30), offset, 270, dimensionStyle);
            dim6.UserText = "DCON = " + Math.Round(dcon / scale, 2);
            dxf.AddEntity(dim6);
            //尺寸7
            if (dhub != 0)
            {
                LinearDimension dim7 = new LinearDimension(new Line(v9, v8), -offset, 270, dimensionStyle);
                dim7.UserText = "DHUB = " + Math.Round(dhub / scale, 2);
                dxf.AddEntity(dim7);
            }
            //尺寸8
            LinearDimension dim8 = new LinearDimension(new Line(v6, v5), offset + (v5.Y - v6.Y) / 2, 0, dimensionStyle);
            dim8.UserText = "LCC = " + Math.Round(lcc / scale, 2);
            dxf.AddEntity(dim8);
            //尺寸9
            LinearDimension dim9 = new LinearDimension(new Line(v1, v4), offset + (v1.X - v4.X) / 2, 270, dimensionStyle);
            dim9.UserText = "CDX = " + Math.Round(cdx / scale, 2);
            dxf.AddEntity(dim9);
            //尺寸10
            Angular2LineDimension angdim1 = new Angular2LineDimension(new Line(v13, v14), Line28, offset + v14.X - v13.X, dimensionStyle);
            angdim1.UserText = "KAPR = " + Math.Round(kapr / pi * 180, 2) + "°";
            dxf.AddEntity(angdim1);
            //尺寸11
            Angular2LineDimension angdim2 = new Angular2LineDimension(Line26, Line27, offset * 1.5, dimensionStyle);
            angdim2.UserText = "PNA = " + Math.Round(pna / pi * 180, 2) + "°";
            dxf.AddEntity(angdim2);
            //尺寸12
            LinearDimension dim12 = new LinearDimension(new Line(v12, v13), -offset, 0, dimensionStyle);
            dim12.UserText = "FW = " + Math.Round(fw / scale, 2);
            dxf.AddEntity(dim12);
            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(-210 - oal / 2, 148.5));
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            //定义格式，根据路径导出

            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);


            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }

        public static void ConcaveProfileCutter(Dictionary<string, Object> data)  //凹半圆铣刀
        {
            DxfDocument dxf = new DxfDocument();
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);

            //作图
            //参数
            double pi = Math.PI;
            double soal = Convert.ToDouble(data["oal"]);
            double sdc = Convert.ToDouble(data["dc"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0)
            {
                if (sdc < 39 && soal < 90)
                {
                    scale = 4.0;
                }
                else if (sdc < 52 && soal < 120)
                {
                    scale = 3.0;
                }
                else if (sdc < 78 && soal < 180)
                {
                    scale = 2.0;
                }
                else if (sdc < 104 && soal < 240)
                {
                    scale = 1.5;
                }
                else if (sdc < 156 && soal < 360)
                {
                    scale = 1.0;
                }
                else if (sdc < 208 && soal < 480)
                {
                    scale = 0.75;
                }
                else
                {
                    scale = 0.5;
                }
            }
            double dc = Convert.ToDouble(data["dc"]) * scale;
            double dcon = Convert.ToDouble(data["dcon"]) * scale;
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double dhub = Convert.ToDouble(data["dhub"]) * scale;
            double cw = Convert.ToDouble(data["cw"]) * scale;
            double hhub = Convert.ToDouble(data["hhub"]) * scale;
            double bcdpax = Convert.ToDouble(data["bcdpax"]) * scale;
            if (bcdpax == 0)
            {
                bcdpax = 2 * scale;
            }
            double prfrad = Convert.ToDouble(data["prfrad"]) * scale;
            double cdx = (dc - dhub) / 2;
            double isframe = Convert.ToDouble(data["isframe"]);
            string path = Convert.ToString(data["path"]);
            //坐标
            //主视图
            Vector2 v1 = new Vector2(0, dhub / 2);
            Vector2 v2 = new Vector2(-hhub, v1.Y);
            Vector2 v3 = new Vector2(v2.X, dc / 2);
            Vector2 v4 = new Vector2(-oal / 2 + prfrad, v3.Y);
            Vector2 v5 = new Vector2(-oal / 2 - prfrad, v3.Y);
            Vector2 v6 = new Vector2(-oal + hhub, v5.Y);
            Vector2 v7 = new Vector2(v6.X, v2.Y);
            Vector2 v8 = new Vector2(-oal, v7.Y);
            Vector2 v9 = new Vector2(v8.X, -v8.Y);
            Vector2 v10 = new Vector2(v7.X, -v7.Y);
            Vector2 v11 = new Vector2(v6.X, -v6.Y);
            Vector2 v12 = new Vector2(v5.X, -v5.Y);
            Vector2 v13 = new Vector2(v4.X, -v4.Y);
            Vector2 v14 = new Vector2(v3.X, -v3.Y);
            Vector2 v15 = new Vector2(v2.X, -v2.Y);
            Vector2 v16 = new Vector2(v1.X, -v1.Y);
            Vector2 v17 = new Vector2(v4.X + bcdpax, v4.Y);
            Vector2 v18 = new Vector2(v5.X - bcdpax, v5.Y);
            Vector2 v19 = new Vector2(v18.X, -v18.Y);
            Vector2 v20 = new Vector2(v17.X, -v17.Y);
            Vector2 v21 = new Vector2(0, -dcon / 2);
            Vector2 v22 = new Vector2(-oal, v21.Y);
            Vector2 v23 = new Vector2(v22.X, -v22.Y);
            Vector2 v24 = new Vector2(v21.X, -v21.Y);
            Vector2 v25 = new Vector2(-oal - 2, 0);
            Vector2 v26 = new Vector2(2, 0);
            //线段
            //主视图
            Vector2[] Line1 = { v1, v2 };
            fun.drawBLine(dxf, Line1, 0.3, contour);
            Vector2[] Line2 = { new Vector2(v3.X, 0), v3 };
            fun.drawBLine(dxf, Line2, 0.3, contour);
            Vector2[] Line3 = { v3, v4 };
            fun.drawBLine(dxf, Line3, 0.3, contour);
            Vector2[] Line4 = { v6, v5 };
            fun.drawBLine(dxf, Line4, 0.3, contour);
            Vector2[] Line5 = { v6, new Vector2(v6.X, 0) };
            fun.drawBLine(dxf, Line5, 0.3, contour);
            LwPolyline Arc6 = new LwPolyline();
            Arc6.Vertexes.Add(new LwPolylineVertex(v5));
            Arc6.Vertexes.Add(new LwPolylineVertex(v4));
            Arc6.Vertexes[0].Bulge = 1;
            fun.PolyFill(dxf, Arc6, 0.3, contour);
            Vector2[] Line7 = { v7, v8 };
            fun.drawBLine(dxf, Line7, 0.3, contour);
            Vector2[] Line8 = { v8, v9 };
            fun.drawBLine(dxf, Line8, 0.3, contour);
            Vector2[] Line9 = { v9, v10 };
            fun.drawBLine(dxf, Line9, 0.3, contour);
            Vector2[] Line10 = { v10, v11 };
            fun.drawBLine(dxf, Line10, 0.3, contour);
            Vector2[] Line11 = { v11, v12 };
            fun.drawBLine(dxf, Line11, 0.3, contour);
            LwPolyline Arc12 = new LwPolyline();
            Arc12.Vertexes.Add(new LwPolylineVertex(v13));
            Arc12.Vertexes.Add(new LwPolylineVertex(v12));
            Arc12.Vertexes[0].Bulge = 1;
            fun.PolyFill(dxf, Arc12, 0.3, contour);
            Vector2[] Line13 = { v13, v14 };
            fun.drawBLine(dxf, Line13, 0.3, contour);
            Vector2[] Line14 = { v14, v15 };
            fun.drawBLine(dxf, Line14, 0.3, contour);
            Vector2[] Line15 = { v15, v16 };
            fun.drawBLine(dxf, Line15, 0.3, contour);
            Vector2[] Line16 = { v16, v1 };
            fun.drawBLine(dxf, Line16, 0.3, contour);
            Vector2[] Line17 = { v21, v22 };
            fun.drawBLine(dxf, Line17, 0.3, contour);
            LwPolyline Arc18 = new LwPolyline();
            Arc18.Vertexes.Add(new LwPolylineVertex(v18));
            Arc18.Vertexes.Add(new LwPolylineVertex(v17));
            Arc18.Vertexes[0].Bulge = 1;
            fun.PolyFill(dxf, Arc18, 0.3, contour);
            LwPolyline Arc19 = new LwPolyline();
            Arc19.Vertexes.Add(new LwPolylineVertex(v20));
            Arc19.Vertexes.Add(new LwPolylineVertex(v19));
            Arc19.Vertexes[0].Bulge = 1;
            fun.PolyFill(dxf, Arc19, 0.3, contour);
            Vector2[] Line20 = { v23, v24 };
            fun.drawPlinetype(dxf, Line20, 0.15, refin, Linetype.Dashed);
            Vector2[] Line21 = { v25, v26 };
            fun.drawPlinetype(dxf, Line21, 0.15, center, Linetype.Center);
            Arc arc22 = new Arc(new Vector2(-oal / 2, -dc / 2), prfrad, 0, 180);
            //填充
            LwPolyline hatchpoly1 = new LwPolyline();
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v13));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v12));
            hatchpoly1.Vertexes[0].Bulge = 1;
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v19));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v20));
            hatchpoly1.Vertexes[2].Bulge = -1;
            hatchpoly1.IsClosed = true;
            String[] htype1 = new String[100];
            Line[] hline1 = new Line[100];
            Arc[] harc1 = new Arc[100];
            int hnumst1 = hatchpoly1.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst1; i++)
            {
                htype1[i] = hatchpoly1.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype1[i] == "Line")
                {
                    hline1[i] = (Line)hatchpoly1.Explode()[i];
                }
                if (htype1[i] == "Arc")
                {
                    harc1[i] = (Arc)hatchpoly1.Explode()[i];
                }
            }
            fun.hatchsub1(dxf, htype1, hnumst1, 45, 0.25, hline1, harc1, contour);
            LwPolyline hatchpoly2 = new LwPolyline();
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v18));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v17));
            hatchpoly2.Vertexes[0].Bulge = 1;
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v4));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v5));
            hatchpoly2.Vertexes[2].Bulge = -1;
            hatchpoly2.IsClosed = true;
            String[] htype2 = new String[100];
            Line[] hline2 = new Line[100];
            Arc[] harc2 = new Arc[100];
            int hnumst2 = hatchpoly2.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst2; i++)
            {
                htype2[i] = hatchpoly2.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype2[i] == "Line")
                {
                    hline2[i] = (Line)hatchpoly2.Explode()[i];
                }
                if (htype2[i] == "Arc")
                {
                    harc2[i] = (Arc)hatchpoly2.Explode()[i];
                }
            }
            fun.hatchsub1(dxf, htype2, hnumst2, 45, 0.25, hline2, harc2, contour);
            LwPolyline hatchpoly3 = new LwPolyline();
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v11));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v19));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v20));
            hatchpoly3.Vertexes[1].Bulge = -1;
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v14));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v15));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v16));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v21));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v22));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v9));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v10));
            hatchpoly3.IsClosed = true;
            String[] htype3 = new String[100];
            Line[] hline3 = new Line[100];
            Arc[] harc3 = new Arc[100];
            int hnumst3 = hatchpoly3.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst3; i++)
            {
                htype3[i] = hatchpoly3.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype3[i] == "Line")
                {
                    hline3[i] = (Line)hatchpoly3.Explode()[i];
                }
                if (htype3[i] == "Arc")
                {
                    harc3[i] = (Arc)hatchpoly3.Explode()[i];
                }
            }
            fun.hatchsub1(dxf, htype3, hnumst3, 45, 5, hline3, harc3, hatching);
            //标注样式
            //箭头样式
            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 0.2;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            //文本样式
            dimensionStyle.TextHeight = 1.0;
            double offset = 10;
            //线段尺寸标注
            //尺寸1
            LinearDimension dim1 = new LinearDimension(new Line(v3, v6), offset, 0, dimensionStyle);
            dim1.UserText = "CW = " + Math.Round(cw / scale, 2);
            dxf.AddEntity(dim1);
            //尺寸2
            LinearDimension dim2 = new LinearDimension(new Line(v6, v11), -offset * 2 - hhub, 270, dimensionStyle);
            dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
            dxf.AddEntity(dim2);
            //尺寸3
            if (dhub != 0)
            {
                LinearDimension dim3 = new LinearDimension(new Line(v9, v11), -offset - (v9.Y - v11.Y) / 2, 0, dimensionStyle);
                dim3.UserText = "HHUB = " + Math.Round(hhub / scale, 2);
                dxf.AddEntity(dim3);
            }
            //尺寸5
            LinearDimension dim5 = new LinearDimension(new Line(v8, v1), offset * 2 + v3.Y - v1.Y, 0, dimensionStyle);
            dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
            dxf.AddEntity(dim5);
            //尺寸6
            LinearDimension dim6 = new LinearDimension(new Line(v21, v24), offset, 270, dimensionStyle);
            dim6.UserText = "DCON = " + Math.Round(dcon / scale, 2);
            dxf.AddEntity(dim6);
            //尺寸7
            if (dhub != 0)
            {
                LinearDimension dim7 = new LinearDimension(new Line(v9, v8), -offset, 270, dimensionStyle);
                dim7.UserText = "DHUB = " + Math.Round(dhub / scale, 2);
                dxf.AddEntity(dim7);
            }
            //尺寸8
            RadialDimension dimrad8 = new RadialDimension(arc22, 45, -offset, dimensionStyle);//DimensionStyle.Default);
            dimrad8.UserText = "PRFRAD = " + Math.Round(prfrad / scale, 2);
            dxf.AddEntity(dimrad8);
            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(-210 - oal / 2, 148.5));
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            //定义格式，根据路径导出

            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }

        public static void ConvexProfileCutter(Dictionary<string, Object> data)  //凸半圆铣刀
        {
            DxfDocument dxf = new DxfDocument();
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);
            //作图
            //参数
            double pi = Math.PI;
            double soal = Convert.ToDouble(data["oal"]);
            double sdc = Convert.ToDouble(data["dc"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0)
            {
                if (sdc < 39 && soal < 90)
                {
                    scale = 4.0;
                }
                else if (sdc < 52 && soal < 120)
                {
                    scale = 3.0;
                }
                else if (sdc < 78 && soal < 180)
                {
                    scale = 2.0;
                }
                else if (sdc < 104 && soal < 240)
                {
                    scale = 1.5;
                }
                else if (sdc < 156 && soal < 360)
                {
                    scale = 1.0;
                }
                else if (sdc < 208 && soal < 480)
                {
                    scale = 0.75;
                }
                else
                {
                    scale = 0.5;
                }
            }
            double dc = Convert.ToDouble(data["dc"]) * scale;
            double dcon = Convert.ToDouble(data["dcon"]) * scale;
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double dhub = Convert.ToDouble(data["dhub"]) * scale;
            double cw = Convert.ToDouble(data["cw"]) * scale;
            double hhub = Convert.ToDouble(data["hhub"]) * scale;
            double bcdpax = Convert.ToDouble(data["bcdpax"]) * scale;
            if (bcdpax == 0)
            {
                bcdpax = 2 * scale;
            }
            double prfrad = Convert.ToDouble(data["prfrad"]) * scale;
            double cdx = (dc - dhub) / 2;
            double isframe = Convert.ToDouble(data["isframe"]);
            double ang1 = Math.Acos(cw / 2 / prfrad);
            double ang2 = pi / 2 - ang1;
            double ang3 = Math.Acos(prfrad * Math.Sin(ang1) / (prfrad - bcdpax));
            string path = Convert.ToString(data["path"]);
            //坐标
            //主视图
            Vector2 v1 = new Vector2(0, dhub / 2);
            Vector2 v2 = new Vector2(-hhub, v1.Y);
            Vector2 v3 = new Vector2(v2.X, dc / 2 - prfrad * (1 - Math.Sin(ang1)));
            Vector2 v4 = new Vector2(v3.X - (prfrad - bcdpax) * Math.Sin(ang2 - ang3) / Math.Sin(ang1), v3.Y);
            Vector2 v6 = new Vector2(-oal + hhub, v3.Y);
            Vector2 v5 = new Vector2(v6.X + (prfrad - bcdpax) * Math.Sin(ang2 - ang3) / Math.Sin(ang1), v4.Y);
            Vector2 v7 = new Vector2(v6.X, v2.Y);
            Vector2 v8 = new Vector2(-oal, v7.Y);
            Vector2 v9 = new Vector2(v8.X, -v8.Y);
            Vector2 v10 = new Vector2(v7.X, -v7.Y);
            Vector2 v11 = new Vector2(v6.X, -v6.Y);
            Vector2 v12 = new Vector2(v5.X, -v5.Y);
            Vector2 v13 = new Vector2(v4.X, -v4.Y);
            Vector2 v14 = new Vector2(v3.X, -v3.Y);
            Vector2 v15 = new Vector2(v2.X, -v2.Y);
            Vector2 v16 = new Vector2(v1.X, -v1.Y);
            Vector2 v21 = new Vector2(0, -dcon / 2);
            Vector2 v22 = new Vector2(-oal, v21.Y);
            Vector2 v23 = new Vector2(v22.X, -v22.Y);
            Vector2 v24 = new Vector2(v21.X, -v21.Y);
            Vector2 v25 = new Vector2(-oal - 2, 0);
            Vector2 v26 = new Vector2(2, 0);
            //线段
            //主视图
            Vector2[] Line1 = { v1, v2 };
            fun.drawBLine(dxf, Line1, 0.3, contour);
            Vector2[] Line2 = { new Vector2(v3.X, 0), v3 };
            fun.drawBLine(dxf, Line2, 0.3, contour);
            Vector2[] Line3 = { v3, v4 };
            fun.drawBLine(dxf, Line3, 0.3, contour);
            Vector2[] Line4 = { v6, v5 };
            fun.drawBLine(dxf, Line4, 0.3, contour);
            Vector2[] Line5 = { v6, new Vector2(v6.X, 0) };
            fun.drawBLine(dxf, Line5, 0.3, contour);
            LwPolyline Arc6 = new LwPolyline();
            Arc6.Vertexes.Add(new LwPolylineVertex(v3));
            Arc6.Vertexes.Add(new LwPolylineVertex(v6));
            Arc6.Vertexes[0].Bulge = 2 * prfrad * (1 - Math.Sin(ang1)) / cw;
            fun.PolyFill(dxf, Arc6, 0.3, contour);
            Vector2[] Line7 = { v7, v8 };
            fun.drawBLine(dxf, Line7, 0.3, contour);
            Vector2[] Line8 = { v8, v9 };
            fun.drawBLine(dxf, Line8, 0.3, contour);
            Vector2[] Line9 = { v9, v10 };
            fun.drawBLine(dxf, Line9, 0.3, contour);
            Vector2[] Line10 = { v10, v11 };
            fun.drawBLine(dxf, Line10, 0.3, contour);
            Vector2[] Line11 = { v11, v12 };
            fun.drawBLine(dxf, Line11, 0.3, contour);
            LwPolyline Arc12 = new LwPolyline();
            Arc12.Vertexes.Add(new LwPolylineVertex(v11));
            Arc12.Vertexes.Add(new LwPolylineVertex(v14));
            Arc12.Vertexes[0].Bulge = 2 * prfrad * (1 - Math.Sin(ang1)) / cw;
            fun.PolyFill(dxf, Arc12, 0.3, contour);
            Vector2[] Line13 = { v13, v14 };
            fun.drawBLine(dxf, Line13, 0.3, contour);
            Vector2[] Line14 = { v14, v15 };
            fun.drawBLine(dxf, Line14, 0.3, contour);
            Vector2[] Line15 = { v15, v16 };
            fun.drawBLine(dxf, Line15, 0.3, contour);
            Vector2[] Line16 = { v16, v1 };
            fun.drawBLine(dxf, Line16, 0.3, contour);
            Vector2[] Line17 = { v21, v22 };
            fun.drawBLine(dxf, Line17, 0.3, contour);
            LwPolyline Arc18 = new LwPolyline();
            Arc18.Vertexes.Add(new LwPolylineVertex(v4));
            Arc18.Vertexes.Add(new LwPolylineVertex(v5));
            Arc18.Vertexes[0].Bulge = 2 * (prfrad * (1 - Math.Sin(ang1)) - bcdpax) / (v4.X - v5.X);
            fun.PolyFill(dxf, Arc18, 0.3, contour);
            LwPolyline Arc19 = new LwPolyline();
            Arc19.Vertexes.Add(new LwPolylineVertex(v12));
            Arc19.Vertexes.Add(new LwPolylineVertex(v13));
            Arc19.Vertexes[0].Bulge = 2 * (prfrad * (1 - Math.Sin(ang1)) - bcdpax) / (v4.X - v5.X);
            fun.PolyFill(dxf, Arc19, 0.3, contour);
            Vector2[] Line20 = { v23, v24 };
            fun.drawPlinetype(dxf, Line20, 0.15, refin, Linetype.Dashed);
            Vector2[] Line21 = { v25, v26 };
            fun.drawPlinetype(dxf, Line21, 0.15, center, Linetype.Center);
            Arc arc22 = new Arc(new Vector2(-oal / 2, -dc / 2 + prfrad), prfrad, ang1 / pi * 180, 180 - ang1 / pi * 180);
            //填充
            LwPolyline hatchpoly1 = new LwPolyline();
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v12));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v13));
            hatchpoly1.Vertexes[0].Bulge = 2 * (prfrad * (1 - Math.Sin(ang1)) - bcdpax) / (v4.X - v5.X);
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v14));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v11));
            hatchpoly1.Vertexes[2].Bulge = -2 * prfrad * (1 - Math.Sin(ang1)) / cw;
            hatchpoly1.IsClosed = true;
            String[] htype1 = new String[100];
            Line[] hline1 = new Line[100];
            Arc[] harc1 = new Arc[100];
            int hnumst1 = hatchpoly1.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst1; i++)
            {
                htype1[i] = hatchpoly1.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype1[i] == "Line")
                {
                    hline1[i] = (Line)hatchpoly1.Explode()[i];
                }
                if (htype1[i] == "Arc")
                {
                    harc1[i] = (Arc)hatchpoly1.Explode()[i];
                }
            }
            fun.hatchsub1(dxf, htype1, hnumst1, 45, 0.5, hline1, harc1, contour);
            LwPolyline hatchpoly2 = new LwPolyline();
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v4));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v5));
            hatchpoly2.Vertexes[0].Bulge = 2 * (prfrad * (1 - Math.Sin(ang1)) - bcdpax) / (v4.X - v5.X);
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v6));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v3));
            hatchpoly2.Vertexes[2].Bulge = -2 * prfrad * (1 - Math.Sin(ang1)) / cw;
            hatchpoly2.IsClosed = true;
            String[] htype2 = new String[100];
            Line[] hline2 = new Line[100];
            Arc[] harc2 = new Arc[100];
            int hnumst2 = hatchpoly2.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst2; i++)
            {
                htype2[i] = hatchpoly2.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype2[i] == "Line")
                {
                    hline2[i] = (Line)hatchpoly2.Explode()[i];
                }
                if (htype2[i] == "Arc")
                {
                    harc2[i] = (Arc)hatchpoly2.Explode()[i];
                }
            }
            fun.hatchsub1(dxf, htype2, hnumst2, 45, 0.5, hline2, harc2, contour);
            LwPolyline hatchpoly3 = new LwPolyline();
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v11));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v12));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v13));
            hatchpoly3.Vertexes[1].Bulge = 2 * (prfrad * (1 - Math.Sin(ang1)) - bcdpax) / (v4.X - v5.X);
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v14));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v15));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v16));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v21));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v22));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v9));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v10));
            hatchpoly3.IsClosed = true;
            String[] htype3 = new String[100];
            Line[] hline3 = new Line[100];
            Arc[] harc3 = new Arc[100];
            int hnumst3 = hatchpoly3.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst3; i++)
            {
                htype3[i] = hatchpoly3.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype3[i] == "Line")
                {
                    hline3[i] = (Line)hatchpoly3.Explode()[i];
                }
                if (htype3[i] == "Arc")
                {
                    harc3[i] = (Arc)hatchpoly3.Explode()[i];
                }
            }
            fun.hatchsub1(dxf, htype3, hnumst3, 45, 5, hline3, harc3, hatching);
            //标注样式
            //箭头样式
            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 0.2;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            //文本样式
            dimensionStyle.TextHeight = 1.0;
            double offset = 10;
            //线段尺寸标注
            //尺寸1
            LinearDimension dim1 = new LinearDimension(new Line(v3, v6), offset + prfrad * (1 - Math.Sin(ang1)), 0, dimensionStyle);
            dim1.UserText = "CW = " + Math.Round(cw / scale, 2);
            dxf.AddEntity(dim1);
            //尺寸2
            LinearDimension dim2 = new LinearDimension(new Line(new Vector2(-oal / 2, dc / 2), new Vector2(-oal / 2, -dc / 2)), -offset * 3 - oal / 2, 270, dimensionStyle);
            dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
            dxf.AddEntity(dim2);
            //尺寸3
            if (dhub != 0)
            {
                LinearDimension dim3 = new LinearDimension(new Line(v9, v11), -offset - (v9.Y - v11.Y) / 2 - prfrad * (1 - Math.Sin(ang1)), 0, dimensionStyle);
                dim3.UserText = "HHUB = " + Math.Round(hhub / scale, 2);
                dxf.AddEntity(dim3);
            }
            //尺寸4
            LinearDimension dim4 = new LinearDimension(new Line(v6, v11), -offset * 2 - hhub, 270, dimensionStyle);
            dim4.UserText = "BCD = " + Math.Round((v6.Y - v11.Y) / scale, 2);
            dxf.AddEntity(dim4);
            //尺寸5
            LinearDimension dim5 = new LinearDimension(new Line(v8, v1), offset * 2 + v3.Y - v1.Y + prfrad * (1 - Math.Sin(ang1)), 0, dimensionStyle);
            dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
            dxf.AddEntity(dim5);
            //尺寸6
            LinearDimension dim6 = new LinearDimension(new Line(v21, v24), offset, 270, dimensionStyle);
            dim6.UserText = "DCON = " + Math.Round(dcon / scale, 2);
            dxf.AddEntity(dim6);
            //尺寸7
            if (dhub != 0)
            {
                LinearDimension dim7 = new LinearDimension(new Line(v9, v8), -offset, 270, dimensionStyle);
                dim7.UserText = "DHUB = " + Math.Round(dhub / scale, 2);
                dxf.AddEntity(dim7);
            }
            //尺寸8
            RadialDimension dimrad8 = new RadialDimension(arc22, -135, -cw, dimensionStyle);//DimensionStyle.Default);
            dimrad8.UserText = "PRFRAD = " + Math.Round(prfrad / scale, 2);
            dxf.AddEntity(dimrad8);
            //尺寸9
            LinearDimension dim9 = new LinearDimension(new Line(new Vector2(-oal / 2, dc / 2), v1), offset + oal / 4, 270, dimensionStyle);
            dim9.UserText = "CDX = " + Math.Round(cdx / scale, 2);
            dxf.AddEntity(dim9);
            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(-210 - oal / 2, 148.5));
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            //定义格式，根据路径导出

            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);


            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }

        public static void CornerRoundingCutter(Dictionary<string, Object> data)  //圆角铣刀
        {
            DxfDocument dxf = new DxfDocument();
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);
            //作图
            //参数
            double pi = Math.PI;
            double soal = Convert.ToDouble(data["oal"]);
            double sdc = Convert.ToDouble(data["dc"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0)
            {
                if (sdc < 39 && soal < 90)
                {
                    scale = 4.0;
                }
                else if (sdc < 52 && soal < 120)
                {
                    scale = 3.0;
                }
                else if (sdc < 78 && soal < 180)
                {
                    scale = 2.0;
                }
                else if (sdc < 104 && soal < 240)
                {
                    scale = 1.5;
                }
                else if (sdc < 156 && soal < 360)
                {
                    scale = 1.0;
                }
                else if (sdc < 208 && soal < 480)
                {
                    scale = 0.75;
                }
                else
                {
                    scale = 0.5;
                }
            }
            double dc = Convert.ToDouble(data["dc"]) * scale;
            double dcon = Convert.ToDouble(data["dcon"]) * scale;
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double dhub = Convert.ToDouble(data["dhub"]) * scale;
            double cw = Convert.ToDouble(data["cw"]) * scale;
            double hhub = Convert.ToDouble(data["hhub"]) * scale;
            double dccb = Convert.ToDouble(data["dccb"]) * scale;
            double lccb = Convert.ToDouble(data["lccb"]) * scale;
            double bcdpax = Convert.ToDouble(data["bcdpax"]) * scale;
            if (bcdpax == 0)
            {
                bcdpax = 2 * scale;
            }
            double prfrad = Convert.ToDouble(data["prfrad"]) * scale;
            double bcd = dc - prfrad * 2 - bcdpax * 2;
            double isframe = Convert.ToDouble(data["isframe"]);
            string path = Convert.ToString(data["path"]);
            //坐标
            //主视图
            Vector2 v1 = new Vector2(0, (dc - prfrad * 2) / 2);
            Vector2 v2 = new Vector2(-prfrad, dc / 2);
            Vector2 v3 = new Vector2(-oal + hhub, v2.Y);
            Vector2 v4 = new Vector2(v3.X, dhub / 2);
            Vector2 v5 = new Vector2(-oal, v4.Y);
            Vector2 v6 = new Vector2(v5.X, -v5.Y);
            Vector2 v7 = new Vector2(v4.X, -v4.Y);
            Vector2 v8 = new Vector2(v3.X, -v3.Y);
            Vector2 v9 = new Vector2(v2.X, -v2.Y);
            Vector2 v10 = new Vector2(v1.X, -v1.Y);
            Vector2 v11 = new Vector2(v1.X, v1.Y - bcdpax);
            Vector2 v12 = new Vector2(v2.X - bcdpax, v2.Y - bcdpax);
            Vector2 v13 = new Vector2(v3.X, v3.Y - bcdpax);
            Vector2 v14 = new Vector2(v13.X, -v13.Y);
            Vector2 v15 = new Vector2(v12.X, -v12.Y);
            Vector2 v16 = new Vector2(v11.X, -v11.Y);
            Vector2 v17 = new Vector2(v16.X, -dccb / 2);
            Vector2 v18 = new Vector2(-lccb, v17.Y);
            Vector2 v19 = new Vector2(v18.X, -dcon / 2);
            Vector2 v20 = new Vector2(v6.X, v19.Y);
            Vector2 v21 = new Vector2(v20.X, -v20.Y);
            Vector2 v22 = new Vector2(v19.X, -v19.Y);
            Vector2 v23 = new Vector2(v18.X, -v18.Y);
            Vector2 v24 = new Vector2(v17.X, -v17.Y);
            Vector2 v25 = new Vector2(-oal - 2, 0);
            Vector2 v26 = new Vector2(2, 0);
            double l = Math.Sqrt((v12.Y - v11.Y) * (v12.Y - v11.Y) + (v11.X - v12.X) * (v11.X - v12.X));
            double ang = Math.Asin(l / 2 / (prfrad + bcdpax));
            double h = (prfrad + bcdpax) - l / 2 / Math.Tan(ang);
            //线段
            //主视图
            LwPolyline Arc1 = new LwPolyline();
            Arc1.Vertexes.Add(new LwPolylineVertex(v2));
            Arc1.Vertexes.Add(new LwPolylineVertex(v1));
            Arc1.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) / Math.Sin(pi / 4);
            fun.PolyFill(dxf, Arc1, 0.3, contour);
            Vector2[] Line2 = { v2, v3 };
            fun.drawBLine(dxf, Line2, 0.3, contour);
            Vector2[] Line3 = { v3, new Vector2(v3.X, 0) };
            fun.drawBLine(dxf, Line3, 0.3, contour);
            Vector2[] Line4 = { v4, v5 };
            fun.drawBLine(dxf, Line4, 0.3, contour);
            Vector2[] Line5 = { v5, v6 };
            fun.drawBLine(dxf, Line5, 0.3, contour);
            Vector2[] Line7 = { v6, v7 };
            fun.drawBLine(dxf, Line7, 0.3, contour);
            Vector2[] Line8 = { v7, v8 };
            fun.drawBLine(dxf, Line8, 0.3, contour);
            Vector2[] Line9 = { v8, v9 };
            fun.drawBLine(dxf, Line9, 0.3, contour);
            LwPolyline Arc10 = new LwPolyline();
            Arc10.Vertexes.Add(new LwPolylineVertex(v10));
            Arc10.Vertexes.Add(new LwPolylineVertex(v9));
            Arc10.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) / Math.Sin(pi / 4);
            fun.PolyFill(dxf, Arc10, 0.3, contour);
            Vector2[] Line11 = { v10, v1 };
            fun.drawBLine(dxf, Line11, 0.3, contour);
            LwPolyline Arc12 = new LwPolyline();
            Arc12.Vertexes.Add(new LwPolylineVertex(v12));
            Arc12.Vertexes.Add(new LwPolylineVertex(v11));
            Arc12.Vertexes[0].Bulge = h * 2 / l;
            fun.PolyFill(dxf, Arc12, 0.3, contour);
            Vector2[] Line13 = { v12, v13 };
            fun.drawBLine(dxf, Line13, 0.3, contour);
            Vector2[] Line14 = { v14, v15 };
            fun.drawBLine(dxf, Line14, 0.3, contour);
            LwPolyline Arc15 = new LwPolyline();
            Arc15.Vertexes.Add(new LwPolylineVertex(v16));
            Arc15.Vertexes.Add(new LwPolylineVertex(v15));
            Arc15.Vertexes[0].Bulge = h * 2 / l;
            fun.PolyFill(dxf, Arc15, 0.3, contour);
            Vector2[] Line16 = { v17, v18 };
            fun.drawBLine(dxf, Line16, 0.3, contour);
            Vector2[] Line17 = { v18, new Vector2(v19.X, 0) };
            fun.drawBLine(dxf, Line17, 0.3, contour);
            Vector2[] Line18 = { v19, v20 };
            fun.drawBLine(dxf, Line18, 0.3, contour);
            Vector2[] Line19 = { v21, v22 };
            fun.drawPlinetype(dxf, Line19, 0.15, refin, Linetype.Dashed);
            Vector2[] Line20 = { v23, new Vector2(v23.X, 0) };
            fun.drawPlinetype(dxf, Line20, 0.15, refin, Linetype.Dashed);
            Vector2[] Line21 = { v23, v24 };
            fun.drawPlinetype(dxf, Line21, 0.15, refin, Linetype.Dashed);
            Vector2[] Line22 = { v25, v26 };
            fun.drawPlinetype(dxf, Line22, 0.15, center, Linetype.Center);
            Arc arc23 = new Arc(new Vector2(v10.X, v9.Y), prfrad, 90, 180);
            //填充
            LwPolyline hatchpoly1 = new LwPolyline();
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v12));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v11));
            hatchpoly1.Vertexes[0].Bulge = h * 2 / l;
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v1));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v2));
            hatchpoly1.Vertexes[2].Bulge = -(1 - Math.Cos(pi / 4)) / Math.Sin(pi / 4);
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v3));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v13));
            hatchpoly1.IsClosed = true;
            String[] htype1 = new String[100];
            Line[] hline1 = new Line[100];
            Arc[] harc1 = new Arc[100];
            int hnumst1 = hatchpoly1.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst1; i++)
            {
                htype1[i] = hatchpoly1.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype1[i] == "Line")
                {
                    hline1[i] = (Line)hatchpoly1.Explode()[i];
                }
                if (htype1[i] == "Arc")
                {
                    harc1[i] = (Arc)hatchpoly1.Explode()[i];
                }
            }
            fun.hatchsub1(dxf, htype1, hnumst1, 45, 0.5, hline1, harc1, contour);
            LwPolyline hatchpoly2 = new LwPolyline();
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v15));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v16));
            hatchpoly2.Vertexes[0].Bulge = -h * 2 / l;
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v10));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v9));
            hatchpoly2.Vertexes[2].Bulge = (1 - Math.Cos(pi / 4)) / Math.Sin(pi / 4);
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v8));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v14));
            hatchpoly2.IsClosed = true;
            String[] htype2 = new String[100];
            Line[] hline2 = new Line[100];
            Arc[] harc2 = new Arc[100];
            int hnumst2 = hatchpoly2.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst2; i++)
            {
                htype2[i] = hatchpoly2.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype2[i] == "Line")
                {
                    hline2[i] = (Line)hatchpoly2.Explode()[i];
                }
                if (htype2[i] == "Arc")
                {
                    harc2[i] = (Arc)hatchpoly2.Explode()[i];
                }
            }
            fun.hatchsub1(dxf, htype2, hnumst2, 45, 0.5, hline2, harc2, contour);
            LwPolyline hatchpoly3 = new LwPolyline();
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v16));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v15));
            hatchpoly3.Vertexes[0].Bulge = h * 2 / l;
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v14));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v7));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v6));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v20));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v19));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v18));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v17));
            hatchpoly3.IsClosed = true;
            String[] htype3 = new String[100];
            Line[] hline3 = new Line[100];
            Arc[] harc3 = new Arc[100];
            int hnumst3 = hatchpoly3.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst3; i++)
            {
                htype3[i] = hatchpoly3.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype3[i] == "Line")
                {
                    hline3[i] = (Line)hatchpoly3.Explode()[i];
                }
                if (htype3[i] == "Arc")
                {
                    harc3[i] = (Arc)hatchpoly3.Explode()[i];
                }
            }
            fun.hatchsub1(dxf, htype3, hnumst3, 45, 10 * scale, hline3, harc3, hatching);
            //标注样式
            //箭头样式
            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 0.2;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            //文本样式
            dimensionStyle.TextHeight = 1.0;
            double offset = 10;
            //线段尺寸标注
            //尺寸1
            LinearDimension dim1 = new LinearDimension(new Line(v3, v1), offset + (v3.Y - v1.Y) / 2, 0, dimensionStyle);
            dim1.UserText = "CW = " + Math.Round(cw / scale, 2);
            dxf.AddEntity(dim1);
            //尺寸2
            LinearDimension dim2 = new LinearDimension(new Line(v3, v8), -offset * 2 - hhub, 270, dimensionStyle);
            dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
            dxf.AddEntity(dim2);
            //尺寸3
            if (dhub != 0)
            {
                LinearDimension dim3 = new LinearDimension(new Line(v6, v8), -offset - (v6.Y - v8.Y) / 2, 0, dimensionStyle);
                dim3.UserText = "HHUB = " + Math.Round(hhub / scale, 2);
                dxf.AddEntity(dim3);
            }
            //尺寸4
            LinearDimension dim4 = new LinearDimension(new Line(v16, v11), offset * 3, 270, dimensionStyle);
            dim4.UserText = "BCD = " + Math.Round(bcd / scale, 2);
            dxf.AddEntity(dim4);
            //尺寸5
            LinearDimension dim5 = new LinearDimension(new Line(v5, v1), offset * 2 + v3.Y - (v1.Y + v5.Y) / 2, 0, dimensionStyle);
            dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
            dxf.AddEntity(dim5);
            //尺寸6
            LinearDimension dim6 = new LinearDimension(new Line(v19, v22), offset + lccb, 270, dimensionStyle);
            dim6.UserText = "DCON = " + Math.Round(dcon / scale, 2);
            dxf.AddEntity(dim6);
            //尺寸7
            if (dhub != 0)
            {
                LinearDimension dim7 = new LinearDimension(new Line(v6, v5), -offset, 270, dimensionStyle);
                dim7.UserText = "DHUB = " + Math.Round(dhub / scale, 2);
                dxf.AddEntity(dim7);
            }
            //尺寸8
            RadialDimension dimrad8 = new RadialDimension(arc23, 135, -prfrad, dimensionStyle);//DimensionStyle.Default);
            dimrad8.UserText = "PRFRAD = " + Math.Round(prfrad / scale, 2);
            dxf.AddEntity(dimrad8);
            //尺寸9
            LinearDimension dim9 = new LinearDimension(new Line(v17, v24), offset * 2, 270, dimensionStyle);
            dim9.UserText = "DCCB = " + Math.Round(dccb / scale, 2);
            dxf.AddEntity(dim9);
            //尺寸10
            LinearDimension dim10 = new LinearDimension(new Line(v17, v18), -offset - v18.Y + v8.Y, 0, dimensionStyle);
            dim10.UserText = "LCCB = " + Math.Round(lccb / scale, 2);
            dxf.AddEntity(dim10);
            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(-210 - oal / 2, 148.5));
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            //定义格式，根据路径导出

            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }

        public static void AngularMillingCutter(Dictionary<string, Object> data)  //单角铣刀
        {
            DxfDocument dxf = new DxfDocument();
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);
            //作图
            //参数
            double pi = Math.PI;
            double soal = Convert.ToDouble(data["oal"]);
            double sdc = Convert.ToDouble(data["dc"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0)
            {
                if (sdc < 39 && soal < 90)
                {
                    scale = 4.0;
                }
                else if (sdc < 52 && soal < 120)
                {
                    scale = 3.0;
                }
                else if (sdc < 78 && soal < 180)
                {
                    scale = 2.0;
                }
                else if (sdc < 104 && soal < 240)
                {
                    scale = 1.5;
                }
                else if (sdc < 156 && soal < 360)
                {
                    scale = 1.0;
                }
                else if (sdc < 208 && soal < 480)
                {
                    scale = 0.75;
                }
                else
                {
                    scale = 0.5;
                }
            }
            double dc = Convert.ToDouble(data["dc"]) * scale;
            double dcon = Convert.ToDouble(data["dcon"]) * scale;
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double dhub = Convert.ToDouble(data["dhub"]) * scale;
            double cw = Convert.ToDouble(data["cw"]) * scale;
            double hhub = Convert.ToDouble(data["hhub"]) * scale;
            double dccb = Convert.ToDouble(data["dccb"]) * scale;
            double lccb = Convert.ToDouble(data["lccb"]) * scale;
            double bcdpax = Convert.ToDouble(data["bcdpax"]) * scale;
            if (bcdpax == 0)
            {
                bcdpax = 2 * scale;
            }
            double prfrad = Convert.ToDouble(data["prfrad"]) * scale;
            double bd = Convert.ToDouble(data["bd"]) * scale;
            double kapr = Convert.ToDouble(data["kapr"]) * pi / 180;
            double dc2 = dc - cw * 2 / Math.Tan(kapr) - 2 * prfrad + 2 * prfrad / Math.Tan(kapr / 2);
            double isframe = Convert.ToDouble(data["isframe"]);
            double l = 2 * prfrad * Math.Cos(kapr / 2);
            double h = prfrad * (1 - Math.Sin(kapr / 2));
            string path = Convert.ToString(data["path"]);
            //坐标
            //主视图
            Vector2 v1 = new Vector2(0, dc / 2 - prfrad);
            Vector2 v2 = new Vector2(-prfrad - prfrad * Math.Sin(pi / 2 - kapr), dc / 2 - prfrad + prfrad * Math.Cos(pi / 2 - kapr));
            Vector2 v3 = new Vector2(-cw, dc2 / 2);
            Vector2 v4 = new Vector2(v3.X, bd / 2);
            Vector2 v5 = new Vector2(-oal + hhub, v4.Y);
            Vector2 v6 = new Vector2(v5.X, dhub / 2);
            Vector2 v7 = new Vector2(-oal, v6.Y);
            Vector2 v8 = new Vector2(v7.X, -v7.Y);
            Vector2 v9 = new Vector2(v6.X, -v6.Y);
            Vector2 v10 = new Vector2(v5.X, -v5.Y);
            Vector2 v11 = new Vector2(v4.X, -v4.Y);
            Vector2 v12 = new Vector2(v3.X, -v3.Y);
            Vector2 v13 = new Vector2(v2.X, -v2.Y);
            Vector2 v14 = new Vector2(v1.X, -v1.Y);
            Vector2 v15 = new Vector2(v14.X, -dccb / 2);
            Vector2 v16 = new Vector2(-lccb, v15.Y);
            Vector2 v17 = new Vector2(v16.X, -dcon / 2);
            Vector2 v18 = new Vector2(-oal, v17.Y);
            Vector2 v19 = new Vector2(v18.X, -v18.Y);
            Vector2 v20 = new Vector2(v17.X, -v17.Y);
            Vector2 v21 = new Vector2(v16.X, -v16.Y);
            Vector2 v22 = new Vector2(v15.X, -v15.Y);
            Vector2 v23 = new Vector2(-bcdpax, v22.Y);
            Vector2 v24 = new Vector2(v23.X, v1.Y);
            Vector2 v25 = new Vector2(-prfrad - (prfrad - bcdpax) * Math.Sin(pi / 2 - kapr), dc / 2 - prfrad + (prfrad - bcdpax) * Math.Cos(pi / 2 - kapr));
            Vector2 v26 = new Vector2(v3.X, v3.Y - bcdpax / Math.Sin(kapr));
            Vector2 v27 = new Vector2(v26.X, -v26.Y);
            Vector2 v28 = new Vector2(v25.X, -v25.Y);
            Vector2 v29 = new Vector2(v24.X, -v24.Y);
            Vector2 v30 = new Vector2(v23.X, -v23.Y);
            Vector2 v31 = new Vector2(-oal - 2, 0);
            Vector2 v32 = new Vector2(2, 0);
            Vector2 v33 = new Vector2(v1.X, v1.Y + prfrad / Math.Tan(kapr / 2));
            Vector2 v34 = new Vector2(v1.X, v33.Y * 2 - v1.Y);
            Vector2 v35 = new Vector2(-v2.X, v33.Y * 2 - v2.Y);
            //线段
            //主视图
            LwPolyline Arc1 = new LwPolyline();
            Arc1.Vertexes.Add(new LwPolylineVertex(v1));
            Arc1.Vertexes.Add(new LwPolylineVertex(v2));
            Arc1.Vertexes[0].Bulge = 2 * h / l;
            fun.PolyFill(dxf, Arc1, 0.3, contour);
            Vector2[] Line2 = { v2, v3 };
            fun.drawBLine(dxf, Line2, 0.3, contour);
            Vector2[] Line3 = { v3, new Vector2(v3.X, 0) };
            fun.drawBLine(dxf, Line3, 0.3, contour);
            Vector2[] Line4 = { v4, v5 };
            fun.drawBLine(dxf, Line4, 0.3, contour);
            Vector2[] Line5 = { v5, new Vector2(v5.X, 0) };
            fun.drawBLine(dxf, Line5, 0.3, contour);
            Vector2[] Line7 = { v6, v7 };
            fun.drawBLine(dxf, Line7, 0.3, contour);
            Vector2[] Line8 = { v7, v8 };
            fun.drawBLine(dxf, Line8, 0.3, contour);
            Vector2[] Line9 = { v8, v9 };
            fun.drawBLine(dxf, Line9, 0.3, contour);
            Vector2[] Line10 = { v9, v10 };
            fun.drawBLine(dxf, Line10, 0.3, contour);
            Vector2[] Line11 = { v10, v11 };
            fun.drawBLine(dxf, Line11, 0.3, contour);
            Vector2[] Line12 = { v11, v12 };
            fun.drawBLine(dxf, Line12, 0.3, contour);
            Vector2[] Line13 = { v12, v13 };
            fun.drawBLine(dxf, Line13, 0.3, contour);
            LwPolyline Arc14 = new LwPolyline();
            Arc14.Vertexes.Add(new LwPolylineVertex(v13));
            Arc14.Vertexes.Add(new LwPolylineVertex(v14));
            Arc14.Vertexes[0].Bulge = 2 * h / l;
            fun.PolyFill(dxf, Arc14, 0.3, contour);
            Vector2[] Line15 = { v14, v1 };
            fun.drawBLine(dxf, Line15, 0.3, contour);
            Vector2[] Line16 = { v15, v16 };
            fun.drawBLine(dxf, Line16, 0.3, contour);
            Vector2[] Line17 = { v16, new Vector2(v16.X, 0) };
            fun.drawBLine(dxf, Line17, 0.3, contour);
            Vector2[] Line18 = { v17, v18 };
            fun.drawBLine(dxf, Line18, 0.3, contour);
            Vector2[] Line19 = { v19, v20 };
            fun.drawPlinetype(dxf, Line19, 0.15, refin, Linetype.Dashed);
            Vector2[] Line20 = { v21, new Vector2(v21.X, 0) };
            fun.drawPlinetype(dxf, Line20, 0.15, refin, Linetype.Dashed);
            Vector2[] Line21 = { v21, v22 };
            fun.drawPlinetype(dxf, Line21, 0.15, refin, Linetype.Dashed);
            Vector2[] Line22 = { v31, v32 };
            fun.drawPlinetype(dxf, Line22, 0.15, center, Linetype.Center);
            Vector2[] Line23 = { v23, v24 };
            fun.drawBLine(dxf, Line23, 0.3, contour);
            LwPolyline Arc24 = new LwPolyline();
            Arc24.Vertexes.Add(new LwPolylineVertex(v24));
            Arc24.Vertexes.Add(new LwPolylineVertex(v25));
            Arc24.Vertexes[0].Bulge = 2 * h / l;
            fun.PolyFill(dxf, Arc24, 0.3, contour);
            Vector2[] Line25 = { v25, v26 };
            fun.drawBLine(dxf, Line25, 0.3, contour);
            Vector2[] Line26 = { v27, v28 };
            fun.drawBLine(dxf, Line26, 0.3, contour);
            LwPolyline Arc27 = new LwPolyline();
            Arc27.Vertexes.Add(new LwPolylineVertex(v28));
            Arc27.Vertexes.Add(new LwPolylineVertex(v29));
            Arc27.Vertexes[0].Bulge = 2 * h / l;
            fun.PolyFill(dxf, Arc27, 0.3, contour);
            Vector2[] Line28 = { v29, v30 };
            fun.drawBLine(dxf, Line28, 0.3, contour);
            Arc arc29 = new Arc(new Vector2(-prfrad, v14.Y), prfrad, (-pi + kapr) / pi * 180, 0);
            Line Line30 = new Line(v2, v35);
            Line Line31 = new Line(v1, v34);
            Line30.Layer = dimensioning;
            dxf.AddEntity(Line30);
            Line31.Layer = dimensioning;
            dxf.AddEntity(Line31);
            //填充
            LwPolyline hatchpoly1 = new LwPolyline();
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v24));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v25));
            hatchpoly1.Vertexes[0].Bulge = h * 2 / l;
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v26));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v3));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v2));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v1));
            hatchpoly1.Vertexes[4].Bulge = -h * 2 / l;
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v22));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v23));
            hatchpoly1.IsClosed = true;
            String[] htype1 = new String[100];
            Line[] hline1 = new Line[100];
            Arc[] harc1 = new Arc[100];
            int hnumst1 = hatchpoly1.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst1; i++)
            {
                htype1[i] = hatchpoly1.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype1[i] == "Line")
                {
                    hline1[i] = (Line)hatchpoly1.Explode()[i];
                }
                if (htype1[i] == "Arc")
                {
                    harc1[i] = (Arc)hatchpoly1.Explode()[i];
                }
            }
            fun.hatchsub1(dxf, htype1, hnumst1, 45, 1, hline1, harc1, contour);
            LwPolyline hatchpoly2 = new LwPolyline();
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v29));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v28));
            hatchpoly2.Vertexes[0].Bulge = -h * 2 / l;
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v27));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v12));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v13));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v14));
            hatchpoly2.Vertexes[4].Bulge = h * 2 / l;
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v15));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v30));
            hatchpoly2.IsClosed = true;
            String[] htype2 = new String[100];
            Line[] hline2 = new Line[100];
            Arc[] harc2 = new Arc[100];
            int hnumst2 = hatchpoly2.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst2; i++)
            {
                htype2[i] = hatchpoly2.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype2[i] == "Line")
                {
                    hline2[i] = (Line)hatchpoly2.Explode()[i];
                }
                if (htype2[i] == "Arc")
                {
                    harc2[i] = (Arc)hatchpoly2.Explode()[i];
                }
            }
            fun.hatchsub1(dxf, htype2, hnumst2, 45, 1, hline2, harc2, contour);
            LwPolyline hatchpoly3 = new LwPolyline();
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v28));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v29));
            hatchpoly3.Vertexes[0].Bulge = h * 2 / l;
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v30));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v16));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v17));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v18));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v8));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v9));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v10));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v11));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v27));
            hatchpoly3.IsClosed = true;
            String[] htype3 = new String[100];
            Line[] hline3 = new Line[100];
            Arc[] harc3 = new Arc[100];
            int hnumst3 = hatchpoly3.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst3; i++)
            {
                htype3[i] = hatchpoly3.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype3[i] == "Line")
                {
                    hline3[i] = (Line)hatchpoly3.Explode()[i];
                }
                if (htype3[i] == "Arc")
                {
                    harc3[i] = (Arc)hatchpoly3.Explode()[i];
                }
            }
            fun.hatchsub1(dxf, htype3, hnumst3, 45, 10 * scale, hline3, harc3, hatching);
            //标注样式
            //箭头样式
            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 0.2;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            //文本样式
            dimensionStyle.TextHeight = 1.0;
            double offset = 10;
            //线段尺寸标注
            //尺寸1
            LinearDimension dim1 = new LinearDimension(new Line(v3, v1), offset + dc / 2 - (v3.Y + v1.Y) / 2, 0, dimensionStyle);
            dim1.UserText = "CW = " + Math.Round(cw / scale, 2);
            dxf.AddEntity(dim1);
            //尺寸2
            LinearDimension dim2 = new LinearDimension(new Line(new Vector2(-prfrad, dc / 2), new Vector2(-prfrad, -dc / 2)), offset * 3 + prfrad, 270, dimensionStyle);
            dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
            dxf.AddEntity(dim2);
            //尺寸3
            if (dhub != 0)
            {
                LinearDimension dim3 = new LinearDimension(new Line(v9, v8), -offset - v8.Y - dc / 2, 0, dimensionStyle);
                dim3.UserText = "HHUB = " + Math.Round(hhub / scale, 2);
                dxf.AddEntity(dim3);
            }
            //尺寸4
            if (bd != 0)
            {
                LinearDimension dim4 = new LinearDimension(new Line(v5, v10), -offset * 2 - hhub, 270, dimensionStyle);
                dim4.UserText = "BD = " + Math.Round(bd / scale, 2);
                dxf.AddEntity(dim4);
            }
            //尺寸5
            LinearDimension dim5 = new LinearDimension(new Line(v7, v1), offset * 2 + dc / 2 - (v1.Y + v7.Y) / 2, 0, dimensionStyle);
            dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
            dxf.AddEntity(dim5);
            //尺寸6
            LinearDimension dim6 = new LinearDimension(new Line(v17, v20), offset + lccb, 270, dimensionStyle);
            dim6.UserText = "DCON = " + Math.Round(dcon / scale, 2);
            dxf.AddEntity(dim6);
            //尺寸7
            if (dhub != 0)
            {
                LinearDimension dim7 = new LinearDimension(new Line(v8, v7), -offset, 270, dimensionStyle);
                dim7.UserText = "DHUB = " + Math.Round(dhub / scale, 2);
                dxf.AddEntity(dim7);
            }
            //尺寸8
            RadialDimension dimrad8 = new RadialDimension(arc29, -45, prfrad + offset, dimensionStyle);//DimensionStyle.Default);
            dimrad8.UserText = "PRFRAD = " + Math.Round(prfrad / scale, 2);
            dxf.AddEntity(dimrad8);
            //尺寸9
            LinearDimension dim9 = new LinearDimension(new Line(v15, v22), offset * 2, 270, dimensionStyle);
            dim9.UserText = "DCCB = " + Math.Round(dccb / scale, 2);
            dxf.AddEntity(dim9);
            //尺寸10
            LinearDimension dim10 = new LinearDimension(new Line(v15, v16), -offset - v15.Y - dc / 2, 0, dimensionStyle);
            dim10.UserText = "LCCB = " + Math.Round(lccb / scale, 2);
            dxf.AddEntity(dim10);
            //尺寸11
            LinearDimension dim11 = new LinearDimension(new Line(v3, v12), -offset * 3 - oal + cw, 270, dimensionStyle);
            dim11.UserText = "DC2 = " + Math.Round(dc2 / scale, 2);
            dxf.AddEntity(dim11);
            //尺寸12
            Angular2LineDimension angdim12 = new Angular2LineDimension(new Line(v2, v35), new Line(v1, v34), offset, dimensionStyle);
            angdim12.UserText = "KAPR = " + Math.Round(kapr / pi * 180, 2) + "°";
            dxf.AddEntity(angdim12);
            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(-210 - oal / 2, 148.5));
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            //定义格式，根据路径导出
            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }

        public static void AngularProfileMillingCutter(Dictionary<string, Object> data)  //不对称双角铣刀
        {
            DxfDocument dxf = new DxfDocument();
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);
            //作图
            //参数
            double pi = Math.PI;
            double soal = Convert.ToDouble(data["oal"]);
            double sdc = Convert.ToDouble(data["dc"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0)
            {
                if (sdc < 39 && soal < 90)
                {
                    scale = 4.0;
                }
                else if (sdc < 52 && soal < 120)
                {
                    scale = 3.0;
                }
                else if (sdc < 78 && soal < 180)
                {
                    scale = 2.0;
                }
                else if (sdc < 104 && soal < 240)
                {
                    scale = 1.5;
                }
                else if (sdc < 156 && soal < 360)
                {
                    scale = 1.0;
                }
                else if (sdc < 208 && soal < 480)
                {
                    scale = 0.75;
                }
                else
                {
                    scale = 0.5;
                }
            }
            double dc = Convert.ToDouble(data["dc"]) * scale;
            double dcon = Convert.ToDouble(data["dcon"]) * scale;
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double dhub = Convert.ToDouble(data["dhub"]) * scale;
            double cw = Convert.ToDouble(data["cw"]) * scale;
            double hhub = Convert.ToDouble(data["hhub"]) * scale;
            double dccb = Convert.ToDouble(data["dccb"]) * scale;
            double lccb = Convert.ToDouble(data["lccb"]) * scale;
            double bcdpax = Convert.ToDouble(data["bcdpax"]) * scale;
            if (bcdpax == 0)
            {
                bcdpax = 2 * scale;
            }
            double prfrad = Convert.ToDouble(data["prfrad"]) * scale;
            double bd = Convert.ToDouble(data["bd"]) * scale;
            double lcc = Convert.ToDouble(data["lcc"]) * scale;
            double kapr = Convert.ToDouble(data["kapr"]) * pi / 180;
            double pna = Convert.ToDouble(data["pna"]) * pi / 180;
            double dc2 = (dc / 2 - (cw - lcc) / Math.Tan(kapr) - prfrad + prfrad * Math.Sin(pi / 2 - kapr + pna / 2) / Math.Sin(pna / 2)) * 2;
            double cdx = prfrad - prfrad * Math.Sin(pi / 2 - kapr + pna / 2) / Math.Sin(pna / 2) + lcc * Math.Tan(pi / 2 + kapr - pna);
            double isframe = Convert.ToDouble(data["isframe"]);
            double l = 2 * prfrad * Math.Cos(pna / 2);
            double h = prfrad * (1 - Math.Sin(pna / 2));
            string path = Convert.ToString(data["path"]);
            //坐标
            //主视图
            Vector2 v33 = new Vector2(-lcc - prfrad * Math.Cos(pi / 2 - kapr + pna / 2) / Math.Sin(pna / 2), dc / 2 - prfrad);
            Vector2 v1 = new Vector2(0, dc / 2 - cdx);
            Vector2 v2 = new Vector2(v33.X + prfrad * Math.Sin(pi / 2 + kapr - pna), v33.Y + prfrad * Math.Cos(pi / 2 + kapr - pna));
            Vector2 v3 = new Vector2(v33.X - prfrad * Math.Cos(kapr), v33.Y + prfrad * Math.Sin(kapr));
            Vector2 v4 = new Vector2(-cw, dc2 / 2);
            Vector2 v5 = new Vector2(v4.X, bd / 2);
            Vector2 v6 = new Vector2(-oal + hhub, v5.Y);
            Vector2 v7 = new Vector2(v6.X, dhub / 2);
            Vector2 v8 = new Vector2(-oal, v7.Y);
            Vector2 v9 = new Vector2(v8.X, -v8.Y);
            Vector2 v10 = new Vector2(v7.X, -v7.Y);
            Vector2 v11 = new Vector2(v6.X, -v6.Y);
            Vector2 v12 = new Vector2(v5.X, -v5.Y);
            Vector2 v13 = new Vector2(v4.X, -v4.Y);
            Vector2 v14 = new Vector2(v3.X, -v3.Y);
            Vector2 v15 = new Vector2(v2.X, -v2.Y);
            Vector2 v16 = new Vector2(v1.X, -v1.Y);
            Vector2 v17 = new Vector2(v16.X, -dccb / 2);
            Vector2 v18 = new Vector2(-lccb, v17.Y);
            Vector2 v19 = new Vector2(v18.X, -dcon / 2);
            Vector2 v20 = new Vector2(v9.X, v19.Y);
            Vector2 v21 = new Vector2(v20.X, -v20.Y);
            Vector2 v22 = new Vector2(v19.X, -v19.Y);
            Vector2 v23 = new Vector2(v18.X, -v18.Y);
            Vector2 v24 = new Vector2(v17.X, -v17.Y);
            Vector2 v25 = new Vector2(v1.X, v1.Y - bcdpax / Math.Cos(pi / 2 + kapr - pna));
            Vector2 v26 = new Vector2(v33.X + (prfrad - bcdpax) * Math.Sin(pi / 2 + kapr - pna), v33.Y + (prfrad - bcdpax) * Math.Cos(pi / 2 + kapr - pna));
            Vector2 v27 = new Vector2(v33.X - (prfrad - bcdpax) * Math.Cos(kapr), v33.Y + (prfrad - bcdpax) * Math.Sin(kapr));
            Vector2 v28 = new Vector2(v4.X, v4.Y - bcdpax / Math.Sin(kapr));
            Vector2 v29 = new Vector2(v28.X, -v28.Y);
            Vector2 v30 = new Vector2(v27.X, -v27.Y);
            Vector2 v31 = new Vector2(v26.X, -v26.Y);
            Vector2 v32 = new Vector2(v25.X, -v25.Y);
            Vector2 v34 = new Vector2(v33.X, -v33.Y);
            Vector2 v35 = new Vector2(-oal - 2, 0);
            Vector2 v36 = new Vector2(2, 0);
            Vector2 v37 = new Vector2(v34.X + prfrad * Math.Cos(pi / 2 - kapr + pna / 2) / Math.Sin(pna / 2), v34.Y - prfrad * Math.Sin(pi / 2 - kapr + pna / 2) / Math.Sin(pna / 2));
            Vector2 v39 = new Vector2(v37.X + 10 * Math.Tan(kapr), v37.Y - 10);
            Vector2 v38 = new Vector2(v37.X - 10 / Math.Tan(kapr), v39.Y);
            Vector2 v43 = new Vector2(v37.X, -v37.Y);
            Vector2 v40 = new Vector2(0, v43.Y + lcc / Math.Tan(kapr));
            Vector2 v41 = new Vector2(0, v40.Y + 10);
            Vector2 v42 = new Vector2(10 * Math.Tan(kapr), v41.Y);
            //线段
            //主视图
            Vector2[] Line1 = { v1, v2 };
            fun.drawBLine(dxf, Line1, 0.3, contour);
            LwPolyline Arc2 = new LwPolyline();
            Arc2.Vertexes.Add(new LwPolylineVertex(v2));
            Arc2.Vertexes.Add(new LwPolylineVertex(v3));
            Arc2.Vertexes[0].Bulge = 2 * h / l;
            fun.PolyFill(dxf, Arc2, 0.3, contour);
            Vector2[] Line3 = { v3, v4 };
            fun.drawBLine(dxf, Line3, 0.3, contour);
            Vector2[] Line4 = { v4, new Vector2(v4.X, 0) };
            fun.drawBLine(dxf, Line4, 0.3, contour);
            Vector2[] Line5 = { v5, v6 };
            fun.drawBLine(dxf, Line5, 0.3, contour);
            Vector2[] Line6 = { v6, new Vector2(v6.X, 0) };
            fun.drawBLine(dxf, Line6, 0.3, contour);
            Vector2[] Line7 = { v7, v8 };
            fun.drawBLine(dxf, Line7, 0.3, contour);
            Vector2[] Line8 = { v8, v9 };
            fun.drawBLine(dxf, Line8, 0.3, contour);
            Vector2[] Line9 = { v9, v10 };
            fun.drawBLine(dxf, Line9, 0.3, contour);
            Vector2[] Line10 = { v10, v11 };
            fun.drawBLine(dxf, Line10, 0.3, contour);
            Vector2[] Line11 = { v11, v12 };
            fun.drawBLine(dxf, Line11, 0.3, contour);
            Vector2[] Line12 = { v12, v13 };
            fun.drawBLine(dxf, Line12, 0.3, contour);
            Vector2[] Line13 = { v13, v14 };
            fun.drawBLine(dxf, Line13, 0.3, contour);
            LwPolyline Arc14 = new LwPolyline();
            Arc14.Vertexes.Add(new LwPolylineVertex(v14));
            Arc14.Vertexes.Add(new LwPolylineVertex(v15));
            Arc14.Vertexes[0].Bulge = 2 * h / l;
            fun.PolyFill(dxf, Arc14, 0.3, contour);
            Vector2[] Line15 = { v15, v16 };
            fun.drawBLine(dxf, Line15, 0.3, contour);
            Vector2[] Line16 = { v16, v1 };
            fun.drawBLine(dxf, Line16, 0.3, contour);
            Vector2[] Line17 = { v17, v18 };
            fun.drawBLine(dxf, Line17, 0.3, contour);
            Vector2[] Line18 = { v18, new Vector2(v18.X, 0) };
            fun.drawBLine(dxf, Line18, 0.3, contour);
            Vector2[] Line19 = { v19, v20 };
            fun.drawBLine(dxf, Line19, 0.3, contour);
            Vector2[] Line20 = { v21, v22 };
            fun.drawPlinetype(dxf, Line20, 0.15, refin, Linetype.Dashed);
            Vector2[] Line21 = { v23, new Vector2(v23.X, 0) };
            fun.drawPlinetype(dxf, Line21, 0.15, refin, Linetype.Dashed);
            Vector2[] Line22 = { v23, v24 };
            fun.drawPlinetype(dxf, Line22, 0.15, refin, Linetype.Dashed);
            Vector2[] Line23 = { v35, v36 };
            fun.drawPlinetype(dxf, Line23, 0.15, center, Linetype.Center);
            Vector2[] Line24 = { v25, v26 };
            fun.drawBLine(dxf, Line24, 0.3, contour);
            LwPolyline Arc25 = new LwPolyline();
            Arc25.Vertexes.Add(new LwPolylineVertex(v26));
            Arc25.Vertexes.Add(new LwPolylineVertex(v27));
            Arc25.Vertexes[0].Bulge = 2 * h / l;
            fun.PolyFill(dxf, Arc25, 0.3, contour);
            Vector2[] Line26 = { v27, v28 };
            fun.drawBLine(dxf, Line26, 0.3, contour);
            Vector2[] Line27 = { v29, v30 };
            fun.drawBLine(dxf, Line27, 0.3, contour);
            LwPolyline Arc28 = new LwPolyline();
            Arc28.Vertexes.Add(new LwPolylineVertex(v30));
            Arc28.Vertexes.Add(new LwPolylineVertex(v31));
            Arc28.Vertexes[0].Bulge = 2 * h / l;
            fun.PolyFill(dxf, Arc28, 0.3, contour);
            Vector2[] Line29 = { v31, v32 };
            fun.drawBLine(dxf, Line29, 0.3, contour);
            Arc arc30 = new Arc(v34, prfrad, (kapr - pna) / pi * 180, (kapr - pi) / pi * 180);
            Line Line31 = new Line(v15, v38);
            Line Line32 = new Line(v14, v39);
            Line Line33 = new Line(v3, v42);
            Line Line34 = new Line(v1, v41);
            Line31.Layer = dimensioning;
            dxf.AddEntity(Line31);
            Line32.Layer = dimensioning;
            dxf.AddEntity(Line32);
            Line33.Layer = dimensioning;
            dxf.AddEntity(Line33);
            Line34.Layer = dimensioning;
            dxf.AddEntity(Line34);
            //填充
            LwPolyline hatchpoly1 = new LwPolyline();
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v26));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v27));
            hatchpoly1.Vertexes[0].Bulge = h * 2 / l;
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v28));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v4));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v3));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v2));
            hatchpoly1.Vertexes[4].Bulge = -h * 2 / l;
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v1));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v25));
            hatchpoly1.IsClosed = true;
            String[] htype1 = new String[100];
            Line[] hline1 = new Line[100];
            Arc[] harc1 = new Arc[100];
            int hnumst1 = hatchpoly1.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst1; i++)
            {
                htype1[i] = hatchpoly1.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype1[i] == "Line")
                {
                    hline1[i] = (Line)hatchpoly1.Explode()[i];
                }
                if (htype1[i] == "Arc")
                {
                    harc1[i] = (Arc)hatchpoly1.Explode()[i];
                }
            }
            fun.hatchsub1(dxf, htype1, hnumst1, 45, 1, hline1, harc1, contour);
            LwPolyline hatchpoly2 = new LwPolyline();
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v31));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v30));
            hatchpoly2.Vertexes[0].Bulge = -h * 2 / l;
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v29));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v13));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v14));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v15));
            hatchpoly2.Vertexes[4].Bulge = h * 2 / l;
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v16));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v32));
            hatchpoly2.IsClosed = true;
            String[] htype2 = new String[100];
            Line[] hline2 = new Line[100];
            Arc[] harc2 = new Arc[100];
            int hnumst2 = hatchpoly2.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst2; i++)
            {
                htype2[i] = hatchpoly2.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype2[i] == "Line")
                {
                    hline2[i] = (Line)hatchpoly2.Explode()[i];
                }
                if (htype2[i] == "Arc")
                {
                    harc2[i] = (Arc)hatchpoly2.Explode()[i];
                }
            }
            fun.hatchsub1(dxf, htype2, hnumst2, 45, 1, hline2, harc2, contour);
            LwPolyline hatchpoly3 = new LwPolyline();
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v30));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v31));
            hatchpoly3.Vertexes[0].Bulge = h * 2 / l;
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v32));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v17));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v18));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v19));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v20));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v9));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v10));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v11));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v12));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v29));
            hatchpoly3.IsClosed = true;
            String[] htype3 = new String[100];
            Line[] hline3 = new Line[100];
            Arc[] harc3 = new Arc[100];
            int hnumst3 = hatchpoly3.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst3; i++)
            {
                htype3[i] = hatchpoly3.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype3[i] == "Line")
                {
                    hline3[i] = (Line)hatchpoly3.Explode()[i];
                }
                if (htype3[i] == "Arc")
                {
                    harc3[i] = (Arc)hatchpoly3.Explode()[i];
                }
            }
            fun.hatchsub1(dxf, htype3, hnumst3, 45, 10 * scale, hline3, harc3, hatching);
            //标注样式
            //箭头样式
            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 0.2;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            //文本样式
            dimensionStyle.TextHeight = 1.0;
            double offset = 10;
            //线段尺寸标注
            //尺寸1
            LinearDimension dim1 = new LinearDimension(new Line(v4, v1), offset * 3 + dc / 2 - (v4.Y + v1.Y) / 2, 0, dimensionStyle);
            dim1.UserText = "CW = " + Math.Round(cw / scale, 2);
            dxf.AddEntity(dim1);
            //尺寸2
            LinearDimension dim2 = new LinearDimension(new Line(new Vector2(v33.X, dc / 2), new Vector2(v34.X, -dc / 2)), offset * 3 - v33.X, 270, dimensionStyle);
            dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
            dxf.AddEntity(dim2);
            //尺寸3
            if (dhub != 0)
            {
                LinearDimension dim3 = new LinearDimension(new Line(v7, v8), offset + dc / 2 - v7.Y, 0, dimensionStyle);
                dim3.UserText = "HHUB = " + Math.Round(hhub / scale, 2);
                dxf.AddEntity(dim3);
            }
            //尺寸4
            if (bd != 0)
            {
                LinearDimension dim4 = new LinearDimension(new Line(v6, v11), -offset * 2 - hhub, 270, dimensionStyle);
                dim4.UserText = "BD = " + Math.Round(bd / scale, 2);
                dxf.AddEntity(dim4);
            }
            //尺寸5
            LinearDimension dim5 = new LinearDimension(new Line(v8, v1), offset * 4 + dc / 2 - (v1.Y + v8.Y) / 2, 0, dimensionStyle);
            dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
            dxf.AddEntity(dim5);
            //尺寸6
            LinearDimension dim6 = new LinearDimension(new Line(v19, v22), offset + lccb, 270, dimensionStyle);
            dim6.UserText = "DCON = " + Math.Round(dcon / scale, 2);
            dxf.AddEntity(dim6);
            //尺寸7
            if (dhub != 0)
            {
                LinearDimension dim7 = new LinearDimension(new Line(v8, v9), -offset, 270, dimensionStyle);
                dim7.UserText = "DHUB = " + Math.Round(dhub / scale, 2);
                dxf.AddEntity(dim7);
            }
            //尺寸8
            RadialDimension dimrad8 = new RadialDimension(arc30, -45, prfrad + offset, dimensionStyle);//DimensionStyle.Default);
            dimrad8.UserText = "PRFRAD = " + Math.Round(prfrad / scale, 2);
            dxf.AddEntity(dimrad8);
            //尺寸9
            LinearDimension dim9 = new LinearDimension(new Line(v17, v24), offset * 2, 270, dimensionStyle);
            dim9.UserText = "DCCB = " + Math.Round(dccb / scale, 2);
            dxf.AddEntity(dim9);
            //尺寸10
            LinearDimension dim10 = new LinearDimension(new Line(v23, v24), offset * 2 + dc / 2 - v23.Y, 0, dimensionStyle);
            dim10.UserText = "LCCB = " + Math.Round(lccb / scale, 2);
            dxf.AddEntity(dim10);
            //尺寸11
            LinearDimension dim11 = new LinearDimension(new Line(v4, v13), -offset * 3 - oal + cw, 270, dimensionStyle);
            dim11.UserText = "DC2 = " + Math.Round(dc2 / scale, 2);
            dxf.AddEntity(dim11);
            //尺寸12
            Angular2LineDimension angdim12 = new Angular2LineDimension(new Line(v37, v38), new Line(v37, v39), offset, dimensionStyle);
            angdim12.UserText = "PNA = " + Math.Round(pna / pi * 180, 2) + "°";
            dxf.AddEntity(angdim12);
            //尺寸13
            LinearDimension dim13 = new LinearDimension(new Line(v43, v1), offset + (v43.Y - v1.Y) / 2, 0, dimensionStyle);
            dim13.UserText = "LCC = " + Math.Round(lcc / scale, 2);
            dxf.AddEntity(dim13);
            //尺寸14
            LinearDimension dim14 = new LinearDimension(new Line(new Vector2(v33.X, dc / 2), v1), offset - v33.X, 270, dimensionStyle);
            dim14.UserText = "CDX = " + Math.Round(cdx / scale, 2);
            dxf.AddEntity(dim14);
            //尺寸15
            Angular2LineDimension angdim15 = new Angular2LineDimension(new Line(v40, v41), new Line(v40, v42), offset * 2, dimensionStyle);
            angdim15.UserText = "KAPR = " + Math.Round(kapr / pi * 180, 2) + "°";
            dxf.AddEntity(angdim15);
            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(-210 - oal / 2, 148.5));
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            //定义格式，根据路径导出
            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
        public static void SawingBlade(Dictionary<string, Object> data)  //锯片铣刀
        {
            DxfDocument dxf = new DxfDocument();
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);

            //作图
            //参数
            //double pi = Math.PI;
            double sdc = Convert.ToDouble(data["dc"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0)
            {
                if (sdc < 45)
                {
                    scale = 4.0;
                }
                else if (sdc < 60)
                {
                    scale = 3.0;
                }
                else if (sdc < 90)
                {
                    scale = 2.0;
                }
                else if (sdc < 120)
                {
                    scale = 1.5;
                }
                else if (sdc < 180)
                {
                    scale = 1.0;
                }
                else if (sdc < 240)
                {
                    scale = 0.75;
                }
                else if (sdc < 360)
                {
                    scale = 0.5;
                }
                else
                {
                    scale = 0.25;
                }
            }
            double dc = Convert.ToDouble(data["dc"]) * scale;
            double dcon = Convert.ToDouble(data["dcon"]) * scale;
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double dhub = Convert.ToDouble(data["dhub"]) * scale;
            double cw = Convert.ToDouble(data["cw"]) * scale;
            double hhub = Convert.ToDouble(data["hhub"]) * scale;
            double dah = Convert.ToDouble(data["dah"]) * scale;
            double dbhc = Convert.ToDouble(data["dbhc"]) * scale;
            double bcdpax = Convert.ToDouble(data["bcdpax"]) * scale;
            if (bcdpax == 0)
            {
                bcdpax = 2 * scale;
            }
            double bcd = Convert.ToDouble(data["bcd"]) * scale;
            double isframe = Convert.ToDouble(data["isframe"]);
            string path = Convert.ToString(data["path"]);
            //坐标
            //主视图
            Vector2 v1 = new Vector2(0, 0);
            Vector2 v2 = new Vector2(0, dbhc / 2);
            Vector2 v3 = new Vector2(dbhc / 2, 0);
            Vector2 v4 = new Vector2(v2.X, -v2.Y);
            Vector2 v5 = new Vector2(-v3.X, 0);
            Vector2 v6 = new Vector2(-oal + hhub, v5.Y);
            Vector2 v7 = new Vector2(-dc / 2 - 2, 0);
            Vector2 v8 = new Vector2(dc / 2 + 2, 0);
            Vector2 v9 = new Vector2(0, dc / 2 + 2);
            Vector2 v10 = new Vector2(0, -v9.Y);
            Vector2 v11 = new Vector2(189 + cw / 2, dc / 2);
            Vector2 v12 = new Vector2(189 + oal / 2 - hhub, bcd / 2);
            Vector2 v13 = new Vector2(v12.X, dhub / 2);
            Vector2 v14 = new Vector2(189 + oal / 2, v13.Y);
            Vector2 v15 = new Vector2(v14.X, -v14.Y);
            Vector2 v16 = new Vector2(v13.X, -v13.Y);
            Vector2 v17 = new Vector2(v12.X, -v12.Y);
            Vector2 v18 = new Vector2(v11.X, -v11.Y);
            Vector2 v19 = new Vector2(189 - cw / 2, v18.Y);
            Vector2 v20 = new Vector2(189 - oal / 2 + hhub, v17.Y);
            Vector2 v21 = new Vector2(v20.X, v16.Y);
            Vector2 v22 = new Vector2(189 - oal / 2, v15.Y);
            Vector2 v23 = new Vector2(v22.X, v14.Y);
            Vector2 v24 = new Vector2(v21.X, v13.Y);
            Vector2 v25 = new Vector2(v20.X, v12.Y);
            Vector2 v26 = new Vector2(v19.X, v11.Y);
            Vector2 v27 = new Vector2(v26.X + bcdpax * (cw - oal + 2 * hhub) / (dc - bcd), v26.Y - bcdpax);
            Vector2 v28 = new Vector2(v11.X - bcdpax * (cw - oal + 2 * hhub) / (dc - bcd), v27.Y);
            Vector2 v29 = new Vector2(v14.X, dbhc / 2 + dah / 2);
            Vector2 v30 = new Vector2(v23.X, v29.Y);
            Vector2 v31 = new Vector2(v30.X, v30.Y - dah);
            Vector2 v32 = new Vector2(v29.X, v31.Y);
            Vector2 v33 = new Vector2(v32.X, dcon / 2);
            Vector2 v34 = new Vector2(v31.X, v33.Y);
            Vector2 v35 = new Vector2(v34.X, -v34.Y);
            Vector2 v36 = new Vector2(v33.X, v35.Y);
            Vector2 v37 = new Vector2(v32.X, -v32.Y);
            Vector2 v38 = new Vector2(v31.X, -v31.Y);
            Vector2 v39 = new Vector2(v30.X, -v30.Y);
            Vector2 v40 = new Vector2(v29.X, -v29.Y);
            Vector2 v41 = new Vector2(v28.X, -v28.Y);
            Vector2 v42 = new Vector2(v27.X, -v27.Y);
            Vector2 v43 = new Vector2(v23.X - 2, 0);
            Vector2 v44 = new Vector2(v14.X + 2, 0);
            Vector2 v45 = new Vector2(v44.X, dbhc / 2);
            Vector2 v46 = new Vector2(v43.X, v45.Y);
            Vector2 v47 = new Vector2(v46.X, -v46.Y);
            Vector2 v48 = new Vector2(v45.X, v47.Y);
            //线段
            //主视图
            fun.drawcircle(dxf, v1, dcon / 2, 0.3, contour);
            LwPolyline Arc1 = new LwPolyline();
            Arc1.Vertexes.Add(new LwPolylineVertex(new Vector2(dbhc / 2, 0)));
            Arc1.Vertexes.Add(new LwPolylineVertex(new Vector2(-dbhc / 2, 0)));
            Arc1.Vertexes[0].Bulge = 1;
            fun.PolyFillandlinetype(dxf, Arc1, 0.15, refin, Linetype.Center);
            LwPolyline Arc2 = new LwPolyline();
            Arc2.Vertexes.Add(new LwPolylineVertex(new Vector2(dbhc / 2, 0)));
            Arc2.Vertexes.Add(new LwPolylineVertex(new Vector2(-dbhc / 2, 0)));
            Arc2.Vertexes[0].Bulge = -1;
            fun.PolyFillandlinetype(dxf, Arc2, 0.15, refin, Linetype.Center);
            fun.drawcircle(dxf, v1, dhub / 2, 0.3, contour);
            fun.drawcircle(dxf, v1, bcd / 2, 0.3, contour);
            fun.drawcircle(dxf, v1, dc / 2, 0.3, contour);
            fun.drawcircle(dxf, v2, dah / 2, 0.3, contour);
            fun.drawcircle(dxf, v3, dah / 2, 0.3, contour);
            fun.drawcircle(dxf, v4, dah / 2, 0.3, contour);
            fun.drawcircle(dxf, v5, dah / 2, 0.3, contour);
            Vector2[] Line1 = { v7, v8 };
            fun.drawPlinetype(dxf, Line1, 0.15, center, Linetype.Center);
            Vector2[] Line2 = { v9, v10 };
            fun.drawPlinetype(dxf, Line2, 0.15, center, Linetype.Center);
            Vector2[] Line3 = { v43, v44 };
            fun.drawPlinetype(dxf, Line3, 0.15, center, Linetype.Center);
            Vector2[] Line4 = { v11, v12 };
            fun.drawBLine(dxf, Line4, 0.3, contour);
            Vector2[] Line5 = { v12, v13 };
            fun.drawBLine(dxf, Line5, 0.3, contour);
            Vector2[] Line6 = { v13, v14 };
            fun.drawBLine(dxf, Line6, 0.3, contour);
            Vector2[] Line7 = { v14, v15 };
            fun.drawBLine(dxf, Line7, 0.3, contour);
            Vector2[] Line8 = { v15, v16 };
            fun.drawBLine(dxf, Line8, 0.3, contour);
            Vector2[] Line9 = { v16, v17 };
            fun.drawBLine(dxf, Line9, 0.3, contour);
            Vector2[] Line10 = { v17, v18 };
            fun.drawBLine(dxf, Line10, 0.3, contour);
            Vector2[] Line11 = { v18, v19 };
            fun.drawBLine(dxf, Line11, 0.3, contour);
            Vector2[] Line12 = { v19, v20 };
            fun.drawBLine(dxf, Line12, 0.3, contour);
            Vector2[] Line13 = { v20, v21 };
            fun.drawBLine(dxf, Line13, 0.3, contour);
            Vector2[] Line14 = { v21, v22 };
            fun.drawBLine(dxf, Line14, 0.3, contour);
            Vector2[] Line15 = { v22, v23 };
            fun.drawBLine(dxf, Line15, 0.3, contour);
            Vector2[] Line16 = { v23, v24 };
            fun.drawBLine(dxf, Line16, 0.3, contour);
            Vector2[] Line17 = { v24, v25 };
            fun.drawBLine(dxf, Line17, 0.3, contour);
            Vector2[] Line18 = { v25, v26 };
            fun.drawBLine(dxf, Line18, 0.3, contour);
            Vector2[] Line19 = { v26, v11 };
            fun.drawBLine(dxf, Line19, 0.3, contour);
            Vector2[] Line20 = { v27, v28 };
            fun.drawBLine(dxf, Line20, 0.3, contour);
            Vector2[] Line21 = { v29, v30 };
            fun.drawBLine(dxf, Line21, 0.3, contour);
            Vector2[] Line22 = { v31, v32 };
            fun.drawBLine(dxf, Line22, 0.3, contour);
            Vector2[] Line23 = { v33, v34 };
            fun.drawBLine(dxf, Line23, 0.3, contour);
            Vector2[] Line24 = { v35, v36 };
            fun.drawBLine(dxf, Line24, 0.3, contour);
            Vector2[] Line25 = { v37, v38 };
            fun.drawBLine(dxf, Line25, 0.3, contour);
            Vector2[] Line26 = { v39, v40 };
            fun.drawBLine(dxf, Line26, 0.3, contour);
            Vector2[] Line27 = { v41, v42 };
            fun.drawBLine(dxf, Line27, 0.3, contour);
            Vector2[] Line28 = { v45, v46 };
            fun.drawPlinetype(dxf, Line28, 0.15, center, Linetype.Center);
            Vector2[] Line29 = { v47, v48 };
            fun.drawPlinetype(dxf, Line29, 0.15, center, Linetype.Center);
            //填充
            LwPolyline hatchpoly1 = new LwPolyline();
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v29));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v30));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v23));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v24));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v25));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v27));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v28));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v12));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v13));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v14));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v29));
            hatchpoly1.IsClosed = true;
            String[] htype1 = new String[100];
            Line[] hline1 = new Line[100];
            Arc[] harc1 = new Arc[100];
            int hnumst1 = hatchpoly1.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst1; i++)
            {
                htype1[i] = hatchpoly1.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype1[i] == "Line")
                {
                    hline1[i] = (Line)hatchpoly1.Explode()[i];
                }
                if (htype1[i] == "Arc")
                {
                    harc1[i] = (Arc)hatchpoly1.Explode()[i];
                }
            }
            fun.hatchsub1(dxf, htype1, hnumst1, 45, 10 * scale, hline1, harc1, hatching);
            LwPolyline hatchpoly2 = new LwPolyline();
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v11));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v26));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v27));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v28));
            hatchpoly2.IsClosed = true;
            String[] htype2 = new String[100];
            Line[] hline2 = new Line[100];
            Arc[] harc2 = new Arc[100];
            int hnumst2 = hatchpoly2.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst2; i++)
            {
                htype2[i] = hatchpoly2.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype2[i] == "Line")
                {
                    hline2[i] = (Line)hatchpoly2.Explode()[i];
                }
                if (htype2[i] == "Arc")
                {
                    harc2[i] = (Arc)hatchpoly2.Explode()[i];
                }
            }
            fun.hatchsub1(dxf, htype2, hnumst2, 45, 1, hline2, harc2, contour);
            LwPolyline hatchpoly3 = new LwPolyline();
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v31));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v32));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v33));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v34));
            hatchpoly3.IsClosed = true;
            String[] htype3 = new String[100];
            Line[] hline3 = new Line[100];
            Arc[] harc3 = new Arc[100];
            int hnumst3 = hatchpoly3.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst3; i++)
            {
                htype3[i] = hatchpoly3.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype3[i] == "Line")
                {
                    hline3[i] = (Line)hatchpoly3.Explode()[i];
                }
                if (htype3[i] == "Arc")
                {
                    harc3[i] = (Arc)hatchpoly3.Explode()[i];
                }
            }
            fun.hatchsub1(dxf, htype3, hnumst3, 45, 10 * scale, hline3, harc3, hatching);
            LwPolyline hatchpoly4 = new LwPolyline();
            hatchpoly4.Vertexes.Add(new LwPolylineVertex(v35));
            hatchpoly4.Vertexes.Add(new LwPolylineVertex(v36));
            hatchpoly4.Vertexes.Add(new LwPolylineVertex(v37));
            hatchpoly4.Vertexes.Add(new LwPolylineVertex(v38));
            hatchpoly4.IsClosed = true;
            String[] htype4 = new String[100];
            Line[] hline4 = new Line[100];
            Arc[] harc4 = new Arc[100];
            int hnumst4 = hatchpoly4.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst4; i++)
            {
                htype4[i] = hatchpoly4.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype4[i] == "Line")
                {
                    hline4[i] = (Line)hatchpoly4.Explode()[i];
                }
                if (htype4[i] == "Arc")
                {
                    harc4[i] = (Arc)hatchpoly4.Explode()[i];
                }
            }
            fun.hatchsub1(dxf, htype4, hnumst4, 45, 10 * scale, hline4, harc4, hatching);
            LwPolyline hatchpoly5 = new LwPolyline();
            hatchpoly5.Vertexes.Add(new LwPolylineVertex(v39));
            hatchpoly5.Vertexes.Add(new LwPolylineVertex(v40));
            hatchpoly5.Vertexes.Add(new LwPolylineVertex(v15));
            hatchpoly5.Vertexes.Add(new LwPolylineVertex(v16));
            hatchpoly5.Vertexes.Add(new LwPolylineVertex(v17));
            hatchpoly5.Vertexes.Add(new LwPolylineVertex(v41));
            hatchpoly5.Vertexes.Add(new LwPolylineVertex(v42));
            hatchpoly5.Vertexes.Add(new LwPolylineVertex(v20));
            hatchpoly5.Vertexes.Add(new LwPolylineVertex(v21));
            hatchpoly5.Vertexes.Add(new LwPolylineVertex(v22));
            hatchpoly5.IsClosed = true;
            String[] htype5 = new String[100];
            Line[] hline5 = new Line[100];
            Arc[] harc5 = new Arc[100];
            int hnumst5 = hatchpoly5.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst5; i++)
            {
                htype5[i] = hatchpoly5.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype5[i] == "Line")
                {
                    hline5[i] = (Line)hatchpoly5.Explode()[i];
                }
                if (htype5[i] == "Arc")
                {
                    harc5[i] = (Arc)hatchpoly5.Explode()[i];
                }
            }
            fun.hatchsub1(dxf, htype5, hnumst5, 45, 10 * scale, hline5, harc5, hatching);
            LwPolyline hatchpoly6 = new LwPolyline();
            hatchpoly6.Vertexes.Add(new LwPolylineVertex(v18));
            hatchpoly6.Vertexes.Add(new LwPolylineVertex(v19));
            hatchpoly6.Vertexes.Add(new LwPolylineVertex(v42));
            hatchpoly6.Vertexes.Add(new LwPolylineVertex(v41));
            hatchpoly6.IsClosed = true;
            String[] htype6 = new String[100];
            Line[] hline6 = new Line[100];
            Arc[] harc6 = new Arc[100];
            int hnumst6 = hatchpoly6.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst6; i++)
            {
                htype6[i] = hatchpoly6.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype6[i] == "Line")
                {
                    hline6[i] = (Line)hatchpoly6.Explode()[i];
                }
                if (htype6[i] == "Arc")
                {
                    harc6[i] = (Arc)hatchpoly6.Explode()[i];
                }
            }
            fun.hatchsub1(dxf, htype6, hnumst6, 45, 1, hline6, harc6, contour);
            //标注样式
            //箭头样式
            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 0.2;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            //文本样式
            dimensionStyle.TextHeight = 1.0;
            double offset = 10;
            //线段尺寸标注
            //尺寸1
            LinearDimension dim1 = new LinearDimension(new Line(v19, v18), -offset, 0, dimensionStyle);
            dim1.UserText = "CW = " + Math.Round(cw / scale, 2);
            dxf.AddEntity(dim1);
            //尺寸2
            LinearDimension dim2 = new LinearDimension(new Line(new Vector2(0, dc / 2), new Vector2(0, -dc / 2)), offset * 2 + dc / 2, 270, dimensionStyle);
            dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
            dxf.AddEntity(dim2);
            //尺寸3
            if (dhub != 0)
            {
                LinearDimension dim3 = new LinearDimension(new Line(v15, v16), -(v16.Y - v17.Y) / 2, 0, dimensionStyle);
                dim3.UserText = "HHUB = " + Math.Round(hhub / scale, 2);
                dxf.AddEntity(dim3);
            }
            //尺寸4
            LinearDimension dim4 = new LinearDimension(new Line(new Vector2(0, bcd / 2), new Vector2(0, -bcd / 2)), offset + dc / 2, 270, dimensionStyle);
            dim4.UserText = "BCD = " + Math.Round(bcd / scale, 2);
            dxf.AddEntity(dim4);
            //尺寸5
            LinearDimension dim5 = new LinearDimension(new Line(v22, v15), -v16.Y + v17.Y, 0, dimensionStyle);
            dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
            dxf.AddEntity(dim5);
            //尺寸6
            LinearDimension dim6 = new LinearDimension(new Line(v33, v36), offset, 270, dimensionStyle);
            dim6.UserText = "DCON = " + Math.Round(dcon / scale, 2);
            dxf.AddEntity(dim6);
            //尺寸7
            if (dhub != 0)
            {
                LinearDimension dim7 = new LinearDimension(new Line(new Vector2(dhub / 2, 0), new Vector2(-dhub / 2, 0)), -offset * 2 - dc / 2, 0, dimensionStyle);
                dim7.UserText = "DHUB = " + Math.Round(dhub / scale, 2);
                dxf.AddEntity(dim7);
            }
            //尺寸9
            if (dbhc != 0)
            {
                LinearDimension dim9 = new LinearDimension(new Line(new Vector2(dbhc / 2, 0), new Vector2(-dbhc / 2, 0)), -offset - dc / 2, 0, dimensionStyle);
                dim9.UserText = "DBHC = " + Math.Round(dbhc / scale, 2);
                dxf.AddEntity(dim9);
            }
            //尺寸11
            if (dah != 0)
            {
                LinearDimension dim11 = new LinearDimension(new Line(new Vector2(-dbhc / 2, dah / 2), new Vector2(-dbhc / 2, -dah / 2)), -offset - (dc - dbhc) / 2, 270, dimensionStyle);
                dim11.UserText = "DAH = " + Math.Round(dah / scale, 2);
                dxf.AddEntity(dim11);
            }
            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(-147, 148.5));
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            //定义格式，根据路径导出


            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
    }
}
